From 6ca2e3166bd9cdb84ea512f41600ff350ceed15d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Tue, 4 Oct 2016 18:19:29 -0500 Subject: [PATCH] ... --- lib/cpExtensions/Algorithms/IsoImageSlicer.h | 1 + plugins/CMakeLists.txt | 1 + .../ImageArithmeticFilters/AddImageFilter.cxx | 53 ++++++++ .../ImageArithmeticFilters/AddImageFilter.h | 29 +++++ .../DivideImageFilter.cxx | 53 ++++++++ .../DivideImageFilter.h | 29 +++++ .../DivideOrZeroOutImageFilter.cxx | 57 +++++++++ .../DivideOrZeroOutImageFilter.h | 29 +++++ .../MultiplyImageFilter.cxx | 53 ++++++++ .../MultiplyImageFilter.h | 29 +++++ .../ImageArithmeticFilters/PowImageFilter.cxx | 56 +++++++++ .../ImageArithmeticFilters/PowImageFilter.h | 29 +++++ .../SubtractImageFilter.cxx | 53 ++++++++ .../SubtractImageFilter.h | 29 +++++ .../MinimumMaximumCalculator.cxx | 115 ++++++++++++++++++ .../MinimumMaximumCalculator.h | 29 +++++ 16 files changed, 645 insertions(+) create mode 100644 plugins/ImageArithmeticFilters/AddImageFilter.cxx create mode 100644 plugins/ImageArithmeticFilters/AddImageFilter.h create mode 100644 plugins/ImageArithmeticFilters/DivideImageFilter.cxx create mode 100644 plugins/ImageArithmeticFilters/DivideImageFilter.h create mode 100644 plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx create mode 100644 plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h create mode 100644 plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx create mode 100644 plugins/ImageArithmeticFilters/MultiplyImageFilter.h create mode 100644 plugins/ImageArithmeticFilters/PowImageFilter.cxx create mode 100644 plugins/ImageArithmeticFilters/PowImageFilter.h create mode 100644 plugins/ImageArithmeticFilters/SubtractImageFilter.cxx create mode 100644 plugins/ImageArithmeticFilters/SubtractImageFilter.h create mode 100644 plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx create mode 100644 plugins/ImageGenericFilters/MinimumMaximumCalculator.h diff --git a/lib/cpExtensions/Algorithms/IsoImageSlicer.h b/lib/cpExtensions/Algorithms/IsoImageSlicer.h index 9e7e3ec..dad9c7a 100644 --- a/lib/cpExtensions/Algorithms/IsoImageSlicer.h +++ b/lib/cpExtensions/Algorithms/IsoImageSlicer.h @@ -5,6 +5,7 @@ #ifndef __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__ #define __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__ +#include #include #include #include diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index cbf2528..4e194de 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -6,6 +6,7 @@ SET( _dirlist AnisotropicDiffusion GenericFilters + ImageArithmeticFilters ImageBooleanFilters ImageDistanceMaps ImageGenericFilters diff --git a/plugins/ImageArithmeticFilters/AddImageFilter.cxx b/plugins/ImageArithmeticFilters/AddImageFilter.cxx new file mode 100644 index 0000000..a0398d6 --- /dev/null +++ b/plugins/ImageArithmeticFilters/AddImageFilter.cxx @@ -0,0 +1,53 @@ +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::AddImageFilter:: +AddImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); + this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::AddImageFilter:: +~AddImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageArithmeticFilters::AddImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input0" ); + cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); + else this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageArithmeticFilters::AddImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::AddImageFilter< _TImage, _TImage > _TFilter; + + auto image1 = this->GetInputData< _TImage >( "Input1" ); + if( image1 == NULL ) + this->_Error( "Incompatible second input image." ); + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image0 ); + filter->SetInput( 1, image1 ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/AddImageFilter.h b/plugins/ImageArithmeticFilters/AddImageFilter.h new file mode 100644 index 0000000..7f48c52 --- /dev/null +++ b/plugins/ImageArithmeticFilters/AddImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageArithmeticFilters__AddImageFilter__h__ +#define __cpPluginsImageArithmeticFilters__AddImageFilter__h__ + +#include +#include + +namespace cpPluginsImageArithmeticFilters +{ + /** + */ + class cpPluginsImageArithmeticFilters_EXPORT AddImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + AddImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageBooleanFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image0 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageArithmeticFilters__AddImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/DivideImageFilter.cxx b/plugins/ImageArithmeticFilters/DivideImageFilter.cxx new file mode 100644 index 0000000..a802667 --- /dev/null +++ b/plugins/ImageArithmeticFilters/DivideImageFilter.cxx @@ -0,0 +1,53 @@ +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::DivideImageFilter:: +DivideImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); + this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::DivideImageFilter:: +~DivideImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageArithmeticFilters::DivideImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input0" ); + cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); + else this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageArithmeticFilters::DivideImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::DivideImageFilter< _TImage, _TImage, _TImage > _TFilter; + + auto image1 = this->GetInputData< _TImage >( "Input1" ); + if( image1 == NULL ) + this->_Error( "Incompatible second input image." ); + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image0 ); + filter->SetInput( 1, image1 ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/DivideImageFilter.h b/plugins/ImageArithmeticFilters/DivideImageFilter.h new file mode 100644 index 0000000..7825c8c --- /dev/null +++ b/plugins/ImageArithmeticFilters/DivideImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageArithmeticFilters__DivideImageFilter__h__ +#define __cpPluginsImageArithmeticFilters__DivideImageFilter__h__ + +#include +#include + +namespace cpPluginsImageArithmeticFilters +{ + /** + */ + class cpPluginsImageArithmeticFilters_EXPORT DivideImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + DivideImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageBooleanFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image0 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageArithmeticFilters__DivideImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx new file mode 100644 index 0000000..4a80569 --- /dev/null +++ b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx @@ -0,0 +1,57 @@ +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: +DivideOrZeroOutImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); + this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + + this->m_Parameters.ConfigureAsReal( "Threshold" ); + this->m_Parameters.SetReal( "Threshold", 1e-10 ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: +~DivideOrZeroOutImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input0" ); + cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); + else this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::DivideOrZeroOutImageFilter< _TImage, _TImage, _TImage > _TFilter; + + auto image1 = this->GetInputData< _TImage >( "Input1" ); + if( image1 == NULL ) + this->_Error( "Incompatible second input image." ); + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image0 ); + filter->SetInput( 1, image1 ); + filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h new file mode 100644 index 0000000..e7f6ff0 --- /dev/null +++ b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageArithmeticFilters__DivideOrZeroOutImageFilter__h__ +#define __cpPluginsImageArithmeticFilters__DivideOrZeroOutImageFilter__h__ + +#include +#include + +namespace cpPluginsImageArithmeticFilters +{ + /** + */ + class cpPluginsImageArithmeticFilters_EXPORT DivideOrZeroOutImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + DivideOrZeroOutImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageBooleanFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image0 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageArithmeticFilters__DivideOrZeroOutImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx b/plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx new file mode 100644 index 0000000..3736968 --- /dev/null +++ b/plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx @@ -0,0 +1,53 @@ +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::MultiplyImageFilter:: +MultiplyImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); + this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::MultiplyImageFilter:: +~MultiplyImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageArithmeticFilters::MultiplyImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input0" ); + cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); + else this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageArithmeticFilters::MultiplyImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::MultiplyImageFilter< _TImage, _TImage > _TFilter; + + auto image1 = this->GetInputData< _TImage >( "Input1" ); + if( image1 == NULL ) + this->_Error( "Incompatible second input image." ); + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image0 ); + filter->SetInput( 1, image1 ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/MultiplyImageFilter.h b/plugins/ImageArithmeticFilters/MultiplyImageFilter.h new file mode 100644 index 0000000..8614096 --- /dev/null +++ b/plugins/ImageArithmeticFilters/MultiplyImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageArithmeticFilters__MultiplyImageFilter__h__ +#define __cpPluginsImageArithmeticFilters__MultiplyImageFilter__h__ + +#include +#include + +namespace cpPluginsImageArithmeticFilters +{ + /** + */ + class cpPluginsImageArithmeticFilters_EXPORT MultiplyImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + MultiplyImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageBooleanFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image0 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageArithmeticFilters__MultiplyImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/PowImageFilter.cxx b/plugins/ImageArithmeticFilters/PowImageFilter.cxx new file mode 100644 index 0000000..f0b4c8e --- /dev/null +++ b/plugins/ImageArithmeticFilters/PowImageFilter.cxx @@ -0,0 +1,56 @@ +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::PowImageFilter:: +PowImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", false, false ); + this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + + this->m_Parameters.ConfigureAsReal( "Constant" ); + this->m_Parameters.SetReal( "Constant", 1 ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::PowImageFilter:: +~PowImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageArithmeticFilters::PowImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input0" ); + cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); + else this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageArithmeticFilters::PowImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::PowImageFilter< _TImage, _TImage > _TFilter; + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput1( image0 ); + auto image1 = this->GetInputData< _TImage >( "Input1" ); + if( image1 == NULL ) + filter->SetConstant( this->m_Parameters.GetReal( "Constant" ) ); + else + filter->SetInput2( image1 ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/PowImageFilter.h b/plugins/ImageArithmeticFilters/PowImageFilter.h new file mode 100644 index 0000000..4882c6a --- /dev/null +++ b/plugins/ImageArithmeticFilters/PowImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageArithmeticFilters__PowImageFilter__h__ +#define __cpPluginsImageArithmeticFilters__PowImageFilter__h__ + +#include +#include + +namespace cpPluginsImageArithmeticFilters +{ + /** + */ + class cpPluginsImageArithmeticFilters_EXPORT PowImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + PowImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageBooleanFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image0 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageArithmeticFilters__PowImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/SubtractImageFilter.cxx b/plugins/ImageArithmeticFilters/SubtractImageFilter.cxx new file mode 100644 index 0000000..0b0c1cf --- /dev/null +++ b/plugins/ImageArithmeticFilters/SubtractImageFilter.cxx @@ -0,0 +1,53 @@ +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::SubtractImageFilter:: +SubtractImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); + this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::SubtractImageFilter:: +~SubtractImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageArithmeticFilters::SubtractImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input0" ); + cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); + else this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageArithmeticFilters::SubtractImageFilter:: +_GD0( _TImage* image0 ) +{ + typedef itk::SubtractImageFilter< _TImage, _TImage > _TFilter; + + auto image1 = this->GetInputData< _TImage >( "Input1" ); + if( image1 == NULL ) + this->_Error( "Incompatible second input image." ); + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image0 ); + filter->SetInput( 1, image1 ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/SubtractImageFilter.h b/plugins/ImageArithmeticFilters/SubtractImageFilter.h new file mode 100644 index 0000000..f8e529f --- /dev/null +++ b/plugins/ImageArithmeticFilters/SubtractImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageArithmeticFilters__SubtractImageFilter__h__ +#define __cpPluginsImageArithmeticFilters__SubtractImageFilter__h__ + +#include +#include + +namespace cpPluginsImageArithmeticFilters +{ + /** + */ + class cpPluginsImageArithmeticFilters_EXPORT SubtractImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + SubtractImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageBooleanFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image0 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageArithmeticFilters__SubtractImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx b/plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx new file mode 100644 index 0000000..4c605cd --- /dev/null +++ b/plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx @@ -0,0 +1,115 @@ +#include +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsImageGenericFilters::MinimumMaximumCalculator:: +MinimumMaximumCalculator( ) + : Superclass( ) +{ + this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); + this->_ConfigureOutput< cpPlugins::DataObjects::Mesh >( "Maximum" ); + this->_ConfigureOutput< cpPlugins::DataObjects::Mesh >( "Minimum" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageGenericFilters::MinimumMaximumCalculator:: +~MinimumMaximumCalculator( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageGenericFilters::MinimumMaximumCalculator:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); + else this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageGenericFilters::MinimumMaximumCalculator:: +_GD0( _TImage* input ) +{ + typedef itk::MinimumMaximumImageCalculator< _TImage > _TFilter; + typedef typename _TImage::IndexType _TIndex; + typedef typename _TImage::PointType _TPoint; + + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetImage( input ); + filter->Compute( ); + + _TIndex min_idx = filter->GetIndexOfMinimum( ); + _TIndex max_idx = filter->GetIndexOfMaximum( ); + + _TPoint min_pnt, max_pnt; + input->TransformIndexToPhysicalPoint( min_idx, min_pnt ); + input->TransformIndexToPhysicalPoint( max_idx, max_pnt ); + + auto min_pd = this->GetOutputData< vtkPolyData >( "Minimum" ); + if( min_pd == NULL ) + { + auto points = vtkSmartPointer< vtkPoints >::New( ); + auto verts = vtkSmartPointer< vtkCellArray >::New( ); + auto lines = vtkSmartPointer< vtkCellArray >::New( ); + auto polys = vtkSmartPointer< vtkCellArray >::New( ); + auto strips = vtkSmartPointer< vtkCellArray >::New( ); + auto pd = vtkSmartPointer< vtkPolyData >::New( ); + pd->SetPoints( points ); + pd->SetVerts( verts ); + pd->SetLines( lines ); + pd->SetPolys( polys ); + pd->SetStrips( strips ); + + points->InsertNextPoint( 0, 0, 0 ); + verts->InsertNextCell( 1 ); + verts->InsertCellPoint( 0 ); + + this->GetOutput( "Minimum" )->SetVTK( pd ); + min_pd = this->GetOutputData< vtkPolyData >( "Minimum" ); + + } // fi + + if( _TImage::ImageDimension == 1 ) + min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], 0, 0 ); + else if( _TImage::ImageDimension == 2 ) + min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], 0 ); + else if( _TImage::ImageDimension > 2 ) + min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], min_pnt[ 2 ] ); + + auto max_pd = this->GetOutputData< vtkPolyData >( "Maximum" ); + if( max_pd == NULL ) + { + auto points = vtkSmartPointer< vtkPoints >::New( ); + auto verts = vtkSmartPointer< vtkCellArray >::New( ); + auto lines = vtkSmartPointer< vtkCellArray >::New( ); + auto polys = vtkSmartPointer< vtkCellArray >::New( ); + auto strips = vtkSmartPointer< vtkCellArray >::New( ); + auto pd = vtkSmartPointer< vtkPolyData >::New( ); + pd->SetPoints( points ); + pd->SetVerts( verts ); + pd->SetLines( lines ); + pd->SetPolys( polys ); + pd->SetStrips( strips ); + + points->InsertNextPoint( 0, 0, 0 ); + verts->InsertNextCell( 1 ); + verts->InsertCellPoint( 0 ); + + this->GetOutput( "Maximum" )->SetVTK( pd ); + max_pd = this->GetOutputData< vtkPolyData >( "Maximum" ); + + } // fi + + if( _TImage::ImageDimension == 1 ) + max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], 0, 0 ); + else if( _TImage::ImageDimension == 2 ) + max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], 0 ); + else if( _TImage::ImageDimension > 2 ) + max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], max_pnt[ 2 ] ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageGenericFilters/MinimumMaximumCalculator.h b/plugins/ImageGenericFilters/MinimumMaximumCalculator.h new file mode 100644 index 0000000..bc18f97 --- /dev/null +++ b/plugins/ImageGenericFilters/MinimumMaximumCalculator.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageGenericFilters__MinimumMaximumCalculator__h__ +#define __cpPluginsImageGenericFilters__MinimumMaximumCalculator__h__ + +#include +#include + +namespace cpPluginsImageGenericFilters +{ + /** + */ + class cpPluginsImageGenericFilters_EXPORT MinimumMaximumCalculator + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + MinimumMaximumCalculator, + cpPlugins::BaseObjects::ProcessObject, + ImageFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* input ); + }; + +} // ecapseman + +#endif // __cpPluginsImageGenericFilters__MinimumMaximumCalculator__h__ + +// eof - $RCSfile$ -- 2.47.1