From ab0c05793ef1e36f53824858c8c727142bdac81c Mon Sep 17 00:00:00 2001 From: Hastings Greer Date: Mon, 25 Feb 2019 18:45:09 -0500 Subject: [PATCH] ENH: Wrap ImageBuilding::Build2D Build2D is used to undistort the output of a curved probe. --- include/IntersonArrayCxxImagingContainer.h | 5 +++ src/IntersonArrayCxxImagingContainer.cxx | 45 +++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/IntersonArrayCxxImagingContainer.h b/include/IntersonArrayCxxImagingContainer.h index 905c530..c2cc401 100644 --- a/include/IntersonArrayCxxImagingContainer.h +++ b/include/IntersonArrayCxxImagingContainer.h @@ -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 ); @@ -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 &); diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index d313c3b..0c1b82e 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -28,6 +28,7 @@ limitations under the License. #include #using "IntersonArray.dll" +#using "System.Drawing.dll" #pragma managed @@ -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(), @@ -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(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; @@ -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