]> Creatis software - cpPlugins.git/blob - plugins/ITKLevelSetFilters/LaplacianSegmentationLevelSetImageFilter.cxx
c45c75a8ef752f6c6b799419dbb8aa18f05b54a5
[cpPlugins.git] / plugins / ITKLevelSetFilters / LaplacianSegmentationLevelSetImageFilter.cxx
1 #include <ITKLevelSetFilters/LaplacianSegmentationLevelSetImageFilter.h>
2 #include <cpInstances/DataObjects/Image.h>
3
4 #include <itkLaplacianSegmentationLevelSetImageFilter.h>
5
6 // -------------------------------------------------------------------------
7 cpPluginsITKLevelSetFilters::LaplacianSegmentationLevelSetImageFilter::
8 LaplacianSegmentationLevelSetImageFilter( )
9   : Superclass( )
10 {
11   this->_ConfigureInput< cpInstances::DataObjects::Image >( "Input", true, false );
12   this->_ConfigureInput< cpInstances::DataObjects::Image >( "Feature", true, false );
13   this->_ConfigureOutput< cpInstances::DataObjects::Image >( "Output" );
14
15   this->m_Parameters.ConfigureAsReal( "PropagationScaling", 1 );
16   this->m_Parameters.ConfigureAsReal( "CurvatureScaling", 1 );
17   this->m_Parameters.ConfigureAsReal( "MaximumRMSError", 0.02 );
18   this->m_Parameters.ConfigureAsReal( "IsoSurfaceValue", 0 );
19   this->m_Parameters.ConfigureAsUint( "NumberOfIterations", 100 );
20 }
21
22 // -------------------------------------------------------------------------
23 cpPluginsITKLevelSetFilters::LaplacianSegmentationLevelSetImageFilter::
24 ~LaplacianSegmentationLevelSetImageFilter( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 void cpPluginsITKLevelSetFilters::LaplacianSegmentationLevelSetImageFilter::
30 _GenerateData( )
31 {
32   auto o = this->GetInputData( "Input" );
33   cpPlugins_Demangle_Image_RealPixels_AllDims_1( o, _GD0 )
34     this->_Error( "Invalid input image." );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void cpPluginsITKLevelSetFilters::LaplacianSegmentationLevelSetImageFilter::
40 _GD0( _TImage* image )
41 {
42   auto f = this->GetInputData( "Feature" );
43   cpPlugins_Demangle_Image_RealPixels_2( f, _GD1, _TImage::ImageDimension, image )
44     this->_Error( "Invalid feature image." );
45 }
46
47 // -------------------------------------------------------------------------
48 template< class _TFeature, class _TImage >
49 void cpPluginsITKLevelSetFilters::LaplacianSegmentationLevelSetImageFilter::
50 _GD1( _TFeature* feature, _TImage* image )
51 {
52   typedef typename _TFeature::PixelType _TScalar;
53   typedef
54     itk::LaplacianSegmentationLevelSetImageFilter< _TImage, _TFeature, _TScalar >
55     _TFilter;
56
57   // Configure filter
58   _TFilter* filter = this->_CreateITK< _TFilter >( );
59   filter->SetInput( image );
60   filter->SetFeatureImage( feature );
61   filter->SetPropagationScaling( this->m_Parameters.GetReal( "PropagationScaling" ) );
62   filter->SetCurvatureScaling( this->m_Parameters.GetReal( "CurvatureScaling" ) );
63   filter->SetMaximumRMSError( this->m_Parameters.GetReal( "MaximumRMSError" ) );
64   filter->SetIsoSurfaceValue( this->m_Parameters.GetReal( "IsoSurfaceValue" ) );
65   filter->SetNumberOfIterations( this->m_Parameters.GetUint( "NumberOfIterations" ) );
66   filter->Update( );
67
68   // Connect output
69   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
70 }
71
72 // eof - $RCSfile$