Skip to content

Commit ab0c057

Browse files
committed
ENH: Wrap ImageBuilding::Build2D
Build2D is used to undistort the output of a curved probe.
1 parent 2298e51 commit ab0c057

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

include/IntersonArrayCxxImagingContainer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class IntersonArrayCxx_EXPORT Container
8080
OTHER_ERROR
8181
};
8282

83+
//widthScan and heightScan are the size of the final converted image
8384
ScanConverterError HardInitScanConverter( int depth, int widthScan,
8485
int heightScan, int steering, int depthCfm );
8586

@@ -118,6 +119,10 @@ class IntersonArrayCxx_EXPORT Container
118119

119120
void SetHWControls(IntersonArrayCxx::Controls::HWControls * controls);
120121

122+
//Converts an array of b-mode transducer responses into an undistorted
123+
//2-D image of size widthScan, heightScan.
124+
void Build2D(PixelType * bmode_bytedata, PixelType * image_out);
125+
121126
private:
122127

123128
Container( const Container &);

src/IntersonArrayCxxImagingContainer.cxx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ limitations under the License.
2828
#include <msclr/auto_gcroot.h>
2929

3030
#using "IntersonArray.dll"
31+
#using "System.Drawing.dll"
3132

3233
#pragma managed
3334

@@ -245,7 +246,8 @@ class ContainerImpl
245246
Container::ScanConverterError HardInitScanConverter( int depth,
246247
int widthScan, int heightScan, int steering, int depthCfm )
247248
{
248-
249+
this->widthScan = widthScan;
250+
this->heightScan = heightScan;
249251
return static_cast< Container::ScanConverterError >(
250252
WrappedScanConverter->HardInitScanConverter( depth, widthScan,
251253
heightScan, steering, depthCfm, WrappedCapture.get(),
@@ -332,12 +334,44 @@ class ContainerImpl
332334
{
333335
this->hwControls = controls;
334336
}
337+
void Build2D(Container::PixelType * bmode_bytedata, Container::PixelType * image_out) {
338+
ContainerImpl::ArrayType^ bmode_bytedata_array =
339+
gcnew ArrayType( Container::NBOFLINES, Container::MAX_SAMPLES );
340+
341+
for ( int ii = 0; ii < Container::NBOFLINES; ++ii )
342+
{
343+
for ( int jj = 0; jj < Container::MAX_SAMPLES; ++jj )
344+
{
345+
bmode_bytedata_array[ii, jj] =
346+
bmode_bytedata[Container::MAX_SAMPLES * ii + jj];
347+
}
348+
}
335349

336-
//
350+
System::Drawing::Bitmap^ image =
351+
gcnew System::Drawing::Bitmap(widthScan, heightScan, System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
352+
WrappedImageBuilding->Build2D(image, bmode_bytedata_array, bmode_bytedata_array, WrappedScanConverter.get());
353+
System::Drawing::Imaging::BitmapData^ bmpData = image->LockBits(System::Drawing::Rectangle(0, 0, widthScan, heightScan),
354+
System::Drawing::Imaging::ImageLockMode::ReadOnly,
355+
System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
356+
357+
char* row = reinterpret_cast<char*>(bmpData->Scan0.ToPointer());
358+
for ( int ii = 0; ii < widthScan; ++ii )
359+
{
360+
for ( int jj = 0; jj < heightScan; ++jj )
361+
{
362+
image_out[widthScan * jj + ii] = row[jj];
363+
}
364+
row += bmpData->Stride;
365+
}
366+
367+
}
368+
369+
//
337370
// Begin Wrapped ImageBuilding
338371
//
339372

340373
private:
374+
int widthScan, heightScan;
341375
IntersonArrayCxx::Controls::HWControls * hwControls;
342376
msclr::auto_gcroot< IntersonArray::Imaging::ScanConverter ^ >
343377
WrappedScanConverter;
@@ -557,6 +591,13 @@ ::SetHWControls(IntersonArrayCxx::Controls::HWControls * controls)
557591
Impl->SetHWControls(controls);
558592
}
559593

594+
void
595+
Container
596+
::Build2D(Container::PixelType * bmode_bytedata, Container::PixelType * image_out)
597+
{
598+
Impl->Build2D(bmode_bytedata, image_out);
599+
}
600+
560601
} // end namespace Imaging
561602

562603
} // end namespace IntersonArrayCxx

0 commit comments

Comments
 (0)