1 #include <ITKImageGenericFilters_1/ImageToBoundingBoxFromThreshold.h>
2 #include <cpInstances/DataObjects/Image.h>
3 #include <cpInstances/DataObjects/BoundingBox.h>
6 #include <cpExtensions/Algorithms/ImageToBoundingBoxFromThreshold.h>
8 // -------------------------------------------------------------------------
9 cpPluginsITKImageGenericFilters_1::ImageToBoundingBoxFromThreshold::
10 ImageToBoundingBoxFromThreshold( )
13 this->_ConfigureInput< cpInstances::DataObjects::Image >( "Input", true, false );
14 this->_ConfigureOutput< cpInstances::DataObjects::BoundingBox >( "Output" );
16 this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 );
17 this->m_Parameters.ConfigureAsReal( "UpperThreshold", 1 );
18 this->m_Parameters.ConfigureAsUint( "PAD", 0 );
21 // -------------------------------------------------------------------------
22 cpPluginsITKImageGenericFilters_1::ImageToBoundingBoxFromThreshold::
23 ~ImageToBoundingBoxFromThreshold( )
27 // -------------------------------------------------------------------------
28 void cpPluginsITKImageGenericFilters_1::ImageToBoundingBoxFromThreshold::
31 auto o = this->GetInputData( "Input" );
32 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
33 this->_Error( "Invalid input image." );
36 // -------------------------------------------------------------------------
37 template< class _TImage >
38 void cpPluginsITKImageGenericFilters_1::ImageToBoundingBoxFromThreshold::
39 _GD0( _TImage* image )
42 cpExtensions::Algorithms::ImageToBoundingBoxFromThreshold< _TImage >
46 _TFilter* filter = this->_CreateITK< _TFilter >( );
47 filter->SetImage( image );
48 filter->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
49 filter->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
50 filter->SetPAD( this->m_Parameters.GetUint( "PAD" ) );
54 auto reg = filter->GetRegion( );
55 auto bb = this->GetOutput< cpInstances::DataObjects::BoundingBox >( "Output" );
56 typename _TImage::PointType p0, p1;
57 image->TransformIndexToPhysicalPoint( reg.GetIndex( ), p0 );
58 image->TransformIndexToPhysicalPoint( reg.GetIndex( ) + reg.GetSize( ), p1 );