Skip to content

Commit

Permalink
ENH: Wrap ImageBuilding::Build2D
Browse files Browse the repository at this point in the history
Build2D is used to undistort the output of a curved probe.
  • Loading branch information
HastingsGreer committed Feb 26, 2019
1 parent 2298e51 commit ab0c057
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/IntersonArrayCxxImagingContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class IntersonArrayCxx_EXPORT Container
OTHER_ERROR
};

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

Expand Down Expand Up @@ -118,6 +119,10 @@ class IntersonArrayCxx_EXPORT Container

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

//Converts an array of b-mode transducer responses into an undistorted
//2-D image of size widthScan, heightScan.
void Build2D(PixelType * bmode_bytedata, PixelType * image_out);

private:

Container( const Container &);
Expand Down
45 changes: 43 additions & 2 deletions src/IntersonArrayCxxImagingContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
#include <msclr/auto_gcroot.h>

#using "IntersonArray.dll"
#using "System.Drawing.dll"

#pragma managed

Expand Down Expand Up @@ -245,7 +246,8 @@ class ContainerImpl
Container::ScanConverterError HardInitScanConverter( int depth,
int widthScan, int heightScan, int steering, int depthCfm )
{

this->widthScan = widthScan;
this->heightScan = heightScan;
return static_cast< Container::ScanConverterError >(
WrappedScanConverter->HardInitScanConverter( depth, widthScan,
heightScan, steering, depthCfm, WrappedCapture.get(),
Expand Down Expand Up @@ -332,12 +334,44 @@ class ContainerImpl
{
this->hwControls = controls;
}
void Build2D(Container::PixelType * bmode_bytedata, Container::PixelType * image_out) {
ContainerImpl::ArrayType^ bmode_bytedata_array =
gcnew ArrayType( Container::NBOFLINES, Container::MAX_SAMPLES );

for ( int ii = 0; ii < Container::NBOFLINES; ++ii )
{
for ( int jj = 0; jj < Container::MAX_SAMPLES; ++jj )
{
bmode_bytedata_array[ii, jj] =
bmode_bytedata[Container::MAX_SAMPLES * ii + jj];
}
}

//
System::Drawing::Bitmap^ image =
gcnew System::Drawing::Bitmap(widthScan, heightScan, System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
WrappedImageBuilding->Build2D(image, bmode_bytedata_array, bmode_bytedata_array, WrappedScanConverter.get());
System::Drawing::Imaging::BitmapData^ bmpData = image->LockBits(System::Drawing::Rectangle(0, 0, widthScan, heightScan),
System::Drawing::Imaging::ImageLockMode::ReadOnly,
System::Drawing::Imaging::PixelFormat::Format8bppIndexed);

char* row = reinterpret_cast<char*>(bmpData->Scan0.ToPointer());
for ( int ii = 0; ii < widthScan; ++ii )
{
for ( int jj = 0; jj < heightScan; ++jj )
{
image_out[widthScan * jj + ii] = row[jj];
}
row += bmpData->Stride;
}

}

//
// Begin Wrapped ImageBuilding
//

private:
int widthScan, heightScan;
IntersonArrayCxx::Controls::HWControls * hwControls;
msclr::auto_gcroot< IntersonArray::Imaging::ScanConverter ^ >
WrappedScanConverter;
Expand Down Expand Up @@ -557,6 +591,13 @@ ::SetHWControls(IntersonArrayCxx::Controls::HWControls * controls)
Impl->SetHWControls(controls);
}

void
Container
::Build2D(Container::PixelType * bmode_bytedata, Container::PixelType * image_out)
{
Impl->Build2D(bmode_bytedata, image_out);
}

} // end namespace Imaging

} // end namespace IntersonArrayCxx

0 comments on commit ab0c057

Please sign in to comment.