From b41426f0faaee22357b16793efc0f741b039bc41 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Tue, 22 Nov 2016 18:03:26 -0500 Subject: [PATCH] itk-based LevelSet filters wrapped --- lib/CMakeLists.txt | 5 +- lib/cpInstances/CMakeLists.txt | 38 +++++++++- lib/cpInstances/ComplexImageFilters.i | 8 ++ lib/cpInstances/ExtractImageFilters.i | 4 + lib/cpInstances/ITKAnisotropicSmoothing.i | 12 +++ lib/cpInstances/ITKDifferenceImageFilters.i | 15 ++++ lib/cpInstances/ITKImageFeatureFilters.i | 14 ++++ lib/cpInstances/ITKLevelSetFilters.i | 28 +++++++ lib/cpInstances/ImageInterpolators.i | 7 +- lib/cpInstances/ImageIterators.i | 1 + lib/cpInstances/NeighborhoodImageIterators.i | 12 +-- lib/cpInstances/ScalarImages.i | 9 ++- lib/cpInstances/VectorImages.i | 11 +-- lib/cpPlugins/Interface/Workspace.cxx | 42 ++++++++++ lib/cpPlugins/Interface/Workspace.h | 6 ++ plugins/CMakeLists.txt | 1 + ...resholdSegmentationLevelSetImageFilter.cxx | 76 +++++++++++++++++++ ...ThresholdSegmentationLevelSetImageFilter.h | 32 ++++++++ 18 files changed, 303 insertions(+), 18 deletions(-) create mode 100644 lib/cpInstances/ITKAnisotropicSmoothing.i create mode 100644 lib/cpInstances/ITKDifferenceImageFilters.i create mode 100644 lib/cpInstances/ITKImageFeatureFilters.i create mode 100644 lib/cpInstances/ITKLevelSetFilters.i create mode 100644 plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.cxx create mode 100644 plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.h diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ca17af7..bf5213e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -42,7 +42,10 @@ SUBDIRS(cpInstances) IF(USE_QT4) CompileLibFromDir(cpBaseQtApplication SHARED cpBaseQtApplication) - TARGET_LINK_LIBRARIES(cpBaseQtApplication ${QT_LIBRARIES} cpPlugins) + TARGET_LINK_LIBRARIES( + cpBaseQtApplication + ${QT_LIBRARIES} cpExtensions cpPlugins + ) ENDIF(USE_QT4) ## eof - $RCSfile$ diff --git a/lib/cpInstances/CMakeLists.txt b/lib/cpInstances/CMakeLists.txt index eac073a..4b0e9ad 100644 --- a/lib/cpInstances/CMakeLists.txt +++ b/lib/cpInstances/CMakeLists.txt @@ -23,6 +23,10 @@ SET( ImageSliceFilters ImageSeparableFilters ExtractImageFilters + ITKDifferenceImageFilters + ITKAnisotropicSmoothing + ITKLevelSetFilters + ITKImageFeatureFilters PolyLineParametricPath Simple3DCurve Skeleton @@ -69,7 +73,11 @@ TARGET_LINK_LIBRARIES(${_pfx}ImageIterators ${_pfx}Image) TARGET_LINK_LIBRARIES(${_pfx}ImageInterpolators ${_pfx}Image) TARGET_LINK_LIBRARIES(${_pfx}NeighborhoodImageIterators ${_pfx}Image) TARGET_LINK_LIBRARIES(${_pfx}BaseImageFilters ${_pfx}ImageIterators) -TARGET_LINK_LIBRARIES(${_pfx}ComplexImageFilters ${_pfx}ImageIterators) +TARGET_LINK_LIBRARIES( + ${_pfx}ComplexImageFilters + ${_pfx}ImageIterators + ${_pfx}NeighborhoodImageIterators + ) TARGET_LINK_LIBRARIES( ${_pfx}ImagesIO ${_pfx}ScalarImages @@ -137,6 +145,34 @@ TARGET_LINK_LIBRARIES( ${_pfx}BaseImageFilters ${_pfx}ComplexImageFilters ) +TARGET_LINK_LIBRARIES( + ${_pfx}ITKImageFeatureFilters + ${_pfx}Image + ${_pfx}BaseImageFilters + ${_pfx}ComplexImageFilters + ${_pfx}NeighborhoodImageIterators + ) +TARGET_LINK_LIBRARIES( + ${_pfx}ITKDifferenceImageFilters + ${_pfx}Image + ${_pfx}BaseImageFilters + ${_pfx}ComplexImageFilters + ) +TARGET_LINK_LIBRARIES( + ${_pfx}ITKAnisotropicSmoothing + ${_pfx}ITKDifferenceImageFilters + ) +TARGET_LINK_LIBRARIES( + ${_pfx}ITKLevelSetFilters + ${_pfx}ITKAnisotropicSmoothing + ${_pfx}Image + ${_pfx}ImageIterators + ${_pfx}NeighborhoodImageIterators + ${_pfx}BaseImageFilters + ${_pfx}ImageInterpolators + ${_pfx}ExtractImageFilters + ${_pfx}ITKImageFeatureFilters + ) ## =================================================== ## == Keep track of all created instances libraries == diff --git a/lib/cpInstances/ComplexImageFilters.i b/lib/cpInstances/ComplexImageFilters.i index 999e79b..dc1e9dd 100644 --- a/lib/cpInstances/ComplexImageFilters.i +++ b/lib/cpInstances/ComplexImageFilters.i @@ -8,6 +8,9 @@ define out_reals=#real_types# tinclude itk#filters#:h|hxx tinclude itkImageAlgorithm:h|hxx +tinclude itkNeighborhoodAlgorithm:h|hxx +tinclude itkNeighborhoodOperatorImageFilter:h|hxx +tinclude itkNeighborhoodInnerProduct:h|hxx cinclude complex cinclude itkImage.h @@ -22,6 +25,11 @@ instances itk::#filters#< itk::Image< #in_scalars#, 2 >, itk::Image< #out_scalar instances itk::#filters#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< itk::CovariantVector< #real_types#, #process_dims# >, #process_dims# > > instances itk::#filters#< itk::Image< itk::CovariantVector< #real_types#, #process_dims# >, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > +instances itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< itk::Image< signed char, #process_dims# > > +instances itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< itk::Image< #scalar_pixels#, #process_dims# > > +instances itk::NeighborhoodInnerProduct< itk::Image< #scalar_pixels#, #process_dims# >, #in_reals#, #out_reals# > +instances itk::NeighborhoodOperatorImageFilter< itk::Image< #in_scalars#, #process_dims# >, itk::Image< #out_scalars#, #process_dims# >, #real_types# > + minstances void #_export_# itk::ImageAlgorithm::DispatchedCopy< itk::Image< #scalar_pixels#, 3 >, itk::Image< #scalar_pixels#, 2 > >( itk::Image< #scalar_pixels#, 3 > const*, itk::Image< #scalar_pixels#, 2 >*, itk::Image< #scalar_pixels#, 3 >::RegionType const&, itk::Image< #scalar_pixels#, 2 >::RegionType const&, std::integral_constant< bool, false > ) minstances void #_export_# itk::ImageAlgorithm::DispatchedCopy< itk::Image< #scalar_pixels#, 2 >, itk::Image< #scalar_pixels#, 3 > >( itk::Image< #scalar_pixels#, 2 > const*, itk::Image< #scalar_pixels#, 3 >*, itk::Image< #scalar_pixels#, 2 >::RegionType const&, itk::Image< #scalar_pixels#, 3 >::RegionType const&, std::integral_constant< bool, false > ) diff --git a/lib/cpInstances/ExtractImageFilters.i b/lib/cpInstances/ExtractImageFilters.i index 7a16438..b63591f 100644 --- a/lib/cpInstances/ExtractImageFilters.i +++ b/lib/cpInstances/ExtractImageFilters.i @@ -1,10 +1,14 @@ header #define ITK_MANUAL_INSTANTIATION define filters=RegionOfInterestImageFilter;ExtractImageFilter +define i_scalars=#scalar_pixels# +define o_scalars=#scalar_pixels# tinclude itk#filters#:h|hxx +tinclude itkShiftScaleImageFilter:h|hxx instances itk::#filters#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > instances itk::ExtractImageFilter< itk::Image< #scalar_pixels#, 3 >, itk::Image< #scalar_pixels#, 2 > > +instances itk::ShiftScaleImageFilter< itk::Image< #i_scalars#, #process_dims# >, itk::Image< #o_scalars#, #process_dims# > > ** eof - $RCSfile$ diff --git a/lib/cpInstances/ITKAnisotropicSmoothing.i b/lib/cpInstances/ITKAnisotropicSmoothing.i new file mode 100644 index 0000000..c381d8b --- /dev/null +++ b/lib/cpInstances/ITKAnisotropicSmoothing.i @@ -0,0 +1,12 @@ +header #define ITK_MANUAL_INSTANTIATION + +define functions=ScalarAnisotropicDiffusionFunction;GradientNDAnisotropicDiffusionFunction +define filters=AnisotropicDiffusionImageFilter + +tinclude itk#functions#:h|hxx +tinclude itk#filters#:h|hxx + +instances itk::#functions#< itk::Image< #real_types#, #process_dims# > > +instances itk::#filters#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/lib/cpInstances/ITKDifferenceImageFilters.i b/lib/cpInstances/ITKDifferenceImageFilters.i new file mode 100644 index 0000000..efa3e64 --- /dev/null +++ b/lib/cpInstances/ITKDifferenceImageFilters.i @@ -0,0 +1,15 @@ +header #define ITK_MANUAL_INSTANTIATION + +define base=FiniteDifferenceImageFilter;DenseFiniteDifferenceImageFilter +define functions=FiniteDifferenceFunction + +define i_reals=#real_types# +define o_reals=#real_types# + +tinclude itk#functions#:h|hxx +tinclude itk#base#:h|hxx + +instances itk::#functions#< itk::Image< #i_reals#, #process_dims# > > +instances itk::#base#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #i_reals#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/lib/cpInstances/ITKImageFeatureFilters.i b/lib/cpInstances/ITKImageFeatureFilters.i new file mode 100644 index 0000000..87f6415 --- /dev/null +++ b/lib/cpInstances/ITKImageFeatureFilters.i @@ -0,0 +1,14 @@ +header #define ITK_MANUAL_INSTANTIATION + +define filters=LaplacianImageFilter +define op=LaplacianOperator +define i_reals=#real_types# +define o_reals=#real_types# + +tinclude itk#op#:h|hxx +tinclude itk#filters#:h|hxx + +instances itk::#op#< #i_reals#, #process_dims#, itk::NeighborhoodAllocator< #i_reals# > > +instances itk::#filters#< itk::Image< #i_reals#, #process_dims# >, itk::Image< #o_reals#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/lib/cpInstances/ITKLevelSetFilters.i b/lib/cpInstances/ITKLevelSetFilters.i new file mode 100644 index 0000000..1031051 --- /dev/null +++ b/lib/cpInstances/ITKLevelSetFilters.i @@ -0,0 +1,28 @@ +header #define ITK_MANUAL_INSTANTIATION + +define base=ZeroCrossingImageFilter;SparseFieldLevelSetImageFilter +define filters=SegmentationLevelSetImageFilter;ThresholdSegmentationLevelSetImageFilter +define functions=LevelSetFunction +define ls_functions=SegmentationLevelSetFunction;ThresholdSegmentationLevelSetFunction + +define i_reals=#real_types# +define o_reals=#real_types# + +tinclude itk#functions#:h|hxx +tinclude itk#ls_functions#:h|hxx +tinclude itk#base#:h|hxx +tinclude itk#filters#:h|hxx +tinclude itkSparseFieldLayer:h|hxx +tinclude itkObjectStore:h|hxx + +cinclude itkLinearInterpolateImageFunction.hxx + +instances itk::SparseFieldLayer< itk::SparseFieldLevelSetNode< itk::Index< #process_dims# > > > +instances itk::ObjectStore< itk::SparseFieldLevelSetNode< itk::Index< #process_dims# > > > + +instances itk::#functions#< itk::Image< #i_reals#, #process_dims# > > +instances itk::#ls_functions#< itk::Image< #i_reals#, #process_dims# >, itk::Image< #o_reals#, #process_dims# > > +instances itk::#base#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #i_reals#, #process_dims# > > +instances itk::#filters#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #i_reals#, #process_dims# >, #o_reals# > + +** eof - $RCSfile$ diff --git a/lib/cpInstances/ImageInterpolators.i b/lib/cpInstances/ImageInterpolators.i index c9214b4..22374c3 100644 --- a/lib/cpInstances/ImageInterpolators.i +++ b/lib/cpInstances/ImageInterpolators.i @@ -1,17 +1,20 @@ header #define ITK_MANUAL_INSTANTIATION +define v=FixedArray define i_real=#real_types# define o_real=#real_types# define interp=Linear tinclude itkImageFunction:h|hxx tinclude itk#interp#InterpolateImageFunction:h|hxx +tinclude itkVectorLinearInterpolateImageFunction:h|hxx -NearestNeighbor - +cinclude itk#v#.h cinclude itkImage.h instances itk::ImageFunction< itk::Image< #scalar_pixels#, #process_dims# >, #i_real#, #o_real# > instances itk::#interp#InterpolateImageFunction< itk::Image< #scalar_pixels#, #process_dims# >, #real_types# > +instances itk::VectorLinearInterpolateImageFunction< itk::Image< itk::#v#< #i_real#, #process_dims# >, #process_dims# >, #o_real# > + ** eof - $RCSfile$ diff --git a/lib/cpInstances/ImageIterators.i b/lib/cpInstances/ImageIterators.i index 0cfefb3..909b65c 100644 --- a/lib/cpInstances/ImageIterators.i +++ b/lib/cpInstances/ImageIterators.i @@ -13,6 +13,7 @@ cinclude itk#matrices#.h cinclude itkOffset.h instances itk::#it#< itk::Image< #scalar_pixels#, #process_dims# > > +instances itk::#it#< itk::Image< signed #int_types#, #process_dims# > > instances itk::#it#< itk::Image< std::complex< #real_types# >, #process_dims# > > instances itk::#it#< itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > > instances itk::#it#< itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# > > diff --git a/lib/cpInstances/NeighborhoodImageIterators.i b/lib/cpInstances/NeighborhoodImageIterators.i index 72fc706..2fa591b 100644 --- a/lib/cpInstances/NeighborhoodImageIterators.i +++ b/lib/cpInstances/NeighborhoodImageIterators.i @@ -2,8 +2,10 @@ header #define ITK_MANUAL_INSTANTIATION define it=ConstNeighborhoodIterator;NeighborhoodIterator;ConstShapedNeighborhoodIterator;ShapedNeighborhoodIterator define co=ZeroFluxNeumannBoundaryCondition +define pi=#scalar_pixels#;signed char +define op=Neighborhood;NeighborhoodOperator;DerivativeOperator -tinclude itkNeighborhood:h|hxx +tinclude itk#op#:h|hxx tinclude itk#co#:h|hxx tinclude itk#it#:h|hxx @@ -15,9 +17,9 @@ cinclude itk#diff_tensors#.h cinclude itk#matrices#.h cinclude itkOffset.h -instances itk::NeighborhoodAllocator< #scalar_pixels# > -instances itk::Neighborhood< #scalar_pixels#, #process_dims#, itk::NeighborhoodAllocator< #scalar_pixels# > > -instances itk::#co#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > -instances itk::#it#< itk::Image< #scalar_pixels#, #process_dims# >, itk::#co#< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > > +instances itk::NeighborhoodAllocator< #pi# > +instances itk::#op#< #pi#, #process_dims#, itk::NeighborhoodAllocator< #pi# > > +instances itk::#co#< itk::Image< #pi#, #process_dims# >, itk::Image< #pi#, #process_dims# > > +instances itk::#it#< itk::Image< #pi#, #process_dims# >, itk::#co#< itk::Image< #pi#, #process_dims# >, itk::Image< #pi#, #process_dims# > > > ** eof - $RCSfile$ diff --git a/lib/cpInstances/ScalarImages.i b/lib/cpInstances/ScalarImages.i index cce18c3..1a8606c 100644 --- a/lib/cpInstances/ScalarImages.i +++ b/lib/cpInstances/ScalarImages.i @@ -1,5 +1,6 @@ header #define ITK_MANUAL_INSTANTIATION +define pi=#scalar_pixels#;signed char define base_filters=ImageSource define i2v=VTKImageExport;VTKImageImport;ImageToVTKImageFilter;VTKImageToImageFilter @@ -10,12 +11,12 @@ tinclude itkImageRegion:h|hxx tinclude itk#base_filters#:h|hxx tinclude itk#i2v#:h|hxx -instances itk::ImportImageContainer< unsigned long, #scalar_pixels# > +instances itk::ImportImageContainer< unsigned long, #pi# > instances itk::ImageRegion< #process_dims# > instances itk::ImageBase< #process_dims# > -instances itk::Image< #scalar_pixels#, #process_dims# > -instances itk::#base_filters#< itk::Image< #scalar_pixels#, #process_dims# > > -instances itk::#i2v#< itk::Image< #scalar_pixels#, #visual_dims# > > +instances itk::Image< #pi#, #process_dims# > +instances itk::#base_filters#< itk::Image< #pi#, #process_dims# > > +instances itk::#i2v#< itk::Image< #pi#, #visual_dims# > > minstances #_export_# std::ostream& itk::operator<< < #process_dims# >( std::ostream& a, itk::ImageRegion< #process_dims# > const& b ) diff --git a/lib/cpInstances/VectorImages.i b/lib/cpInstances/VectorImages.i index 17d1a33..4a7c5f3 100644 --- a/lib/cpInstances/VectorImages.i +++ b/lib/cpInstances/VectorImages.i @@ -1,5 +1,6 @@ header #define ITK_MANUAL_INSTANTIATION +define v=FixedArray;#vectors# define base_filters=ImageSource define i2v=VTKImageExport;VTKImageImport;ImageToVTKImageFilter;VTKImageToImageFilter @@ -8,14 +9,14 @@ tinclude itkImage:h|hxx tinclude itk#base_filters#:h|hxx tinclude itk#i2v#:h|hxx -cinclude itk#vectors#.h +cinclude itk#v#.h cinclude itk#diff_tensors#.h cinclude itkOffset.h -instances itk::ImportImageContainer< unsigned long, itk::#vectors#< #real_types#, #process_dims# > > -instances itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# > -instances itk::#base_filters#< itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# > > -instances itk::#i2v#< itk::Image< itk::#vectors#< #real_types#, #visual_dims# >, #visual_dims# > > +instances itk::ImportImageContainer< unsigned long, itk::#v#< #real_types#, #process_dims# > > +instances itk::Image< itk::#v#< #real_types#, #process_dims# >, #process_dims# > +instances itk::#base_filters#< itk::Image< itk::#v#< #real_types#, #process_dims# >, #process_dims# > > +instances itk::#i2v#< itk::Image< itk::#v#< #real_types#, #visual_dims# >, #visual_dims# > > instances itk::ImportImageContainer< unsigned long, itk::#diff_tensors#< #real_types# > > instances itk::Image< itk::#diff_tensors#< #real_types# >, #process_dims# > diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index bdc67e0..5b80a36 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -232,6 +232,48 @@ Connect( return( ok ); } +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::Workspace:: +Connect( + TDataObject* input, + const std::string& destination_filter, + const std::string& destination_input + ) +{ + // Get filters and check pertinence + if( input == NULL ) + return( false ); + TFilter* destination = this->GetFilter( destination_filter ); + if( destination == NULL ) + return( false ); + if( !( destination->HasInput( destination_input ) ) ) + return( false ); + + // Check if there is room for a new connection + bool ok = true; + if( destination->IsInputMultiple( destination_input ) ) + { + for( + unsigned int i = 0; + i < destination->GetInputSize( destination_input ); + ++i + ) + if( + destination->GetInput( destination_input, i )->GetSource( ) == + input->GetSource( ) + ) + ok = false; + } + else + ok = ( destination->GetInput( destination_input ) == NULL ); + if( ok ) + destination->AddInput( + destination_input, + input + ); + return( ok ); +} + // ------------------------------------------------------------------------- bool cpPlugins::Interface::Workspace:: Disconnect( diff --git a/lib/cpPlugins/Interface/Workspace.h b/lib/cpPlugins/Interface/Workspace.h index 1e6e6e2..73db780 100644 --- a/lib/cpPlugins/Interface/Workspace.h +++ b/lib/cpPlugins/Interface/Workspace.h @@ -24,6 +24,7 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; + typedef cpPlugins::BaseObjects::DataObject TDataObject; typedef cpPlugins::BaseObjects::ProcessObject TFilter; typedef cpPlugins::BaseObjects::Widget TWidget; typedef cpPlugins::Interface::Plugins TPlugins; @@ -108,6 +109,11 @@ namespace cpPlugins const std::string& destination_filter, const std::string& destination_input ); + bool Connect( + TDataObject* input, + const std::string& destination_filter, + const std::string& destination_input + ); bool Disconnect( const std::string& origin_filter, const std::string& origin_output, diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index feabf0e..8ad7dd4 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -15,6 +15,7 @@ SET( ITKSliceFilters ITKSeparableFilters ITKGenericFilters + ITKLevelSetFilters ImageParaMorphologyFilters ImageThresholdFilters ImageGradientFilters diff --git a/plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.cxx b/plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.cxx new file mode 100644 index 0000000..45c2b40 --- /dev/null +++ b/plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.cxx @@ -0,0 +1,76 @@ +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsITKLevelSetFilters::ThresholdSegmentationLevelSetImageFilter:: +ThresholdSegmentationLevelSetImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpInstances::Image >( "Input", true, false ); + this->_ConfigureInput< cpInstances::Image >( "Feature", true, false ); + this->_ConfigureOutput< cpInstances::Image >( "Output" ); + + this->m_Parameters.ConfigureAsReal( "PropagationScaling", 1 ); + this->m_Parameters.ConfigureAsReal( "CurvatureScaling", 1 ); + this->m_Parameters.ConfigureAsReal( "MaximumRMSError", 0.02 ); + this->m_Parameters.ConfigureAsReal( "UpperThreshold", 1 ); + this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 ); + this->m_Parameters.ConfigureAsReal( "IsoSurfaceValue", 0 ); + this->m_Parameters.ConfigureAsUint( "NumberOfIterations", 100 ); +} + +// ------------------------------------------------------------------------- +cpPluginsITKLevelSetFilters::ThresholdSegmentationLevelSetImageFilter:: +~ThresholdSegmentationLevelSetImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsITKLevelSetFilters::ThresholdSegmentationLevelSetImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image dimension." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsITKLevelSetFilters::ThresholdSegmentationLevelSetImageFilter:: +_GD0( _TImage* image ) +{ + auto f = this->GetInputData( "Feature" ); + cpPlugins_Demangle_Image_RealPixels_2( f, _GD1, _TImage::ImageDimension, image ) + this->_Error( "Invalid feature image." ); +} + +// ------------------------------------------------------------------------- +template< class _TFeature, class _TImage > +void cpPluginsITKLevelSetFilters::ThresholdSegmentationLevelSetImageFilter:: +_GD1( _TFeature* feature, _TImage* image ) +{ + typedef typename _TFeature::PixelType _TScalar; + typedef + itk::ThresholdSegmentationLevelSetImageFilter< _TImage, _TFeature, _TScalar > + _TFilter; + + // Configure filter + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetFeatureImage( feature ); + filter->SetPropagationScaling( this->m_Parameters.GetReal( "PropagationScaling" ) ); + filter->SetCurvatureScaling( this->m_Parameters.GetReal( "CurvatureScaling" ) ); + filter->SetMaximumRMSError( this->m_Parameters.GetReal( "MaximumRMSError" ) ); + filter->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) ); + filter->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) ); + filter->SetIsoSurfaceValue( this->m_Parameters.GetReal( "IsoSurfaceValue" ) ); + filter->SetNumberOfIterations( this->m_Parameters.GetUint( "NumberOfIterations" ) ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.h b/plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.h new file mode 100644 index 0000000..3adab5a --- /dev/null +++ b/plugins/ITKLevelSetFilters/ThresholdSegmentationLevelSetImageFilter.h @@ -0,0 +1,32 @@ +#ifndef __cpPluginsITKLevelSetFilters__ThresholdSegmentationLevelSetImageFilter__h__ +#define __cpPluginsITKLevelSetFilters__ThresholdSegmentationLevelSetImageFilter__h__ + +#include +#include + +namespace cpPluginsITKLevelSetFilters +{ + /** + */ + class cpPluginsITKLevelSetFilters_EXPORT ThresholdSegmentationLevelSetImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + ThresholdSegmentationLevelSetImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageLevelSetFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image ); + + template< class _TFeature, class _TImage > + inline void _GD1( _TFeature* feature, _TImage* image ); + }; + +} // ecapseman + +#endif // __cpPluginsITKLevelSetFilters__ThresholdSegmentationLevelSetImageFilter__h__ + +// eof - $RCSfile$ -- 2.47.1