25 #ifndef WSEGMENTATIONALGOREGIONGROWINGCONFIDENCECONNECTED_H
26 #define WSEGMENTATIONALGOREGIONGROWINGCONFIDENCECONNECTED_H
34 #include "WSegmentationAlgo.h"
35 #include "core/dataHandler/WITKImageConversion.h"
36 #include "core/graphicsEngine/WROIBox.h"
37 #include "core/kernel/WKernel.h"
38 #include "core/kernel/WROIManager.h"
39 #include "itkCastImageFilter.h"
40 #include "itkConfidenceConnectedImageFilter.h"
41 #include "itkGradientAnisotropicDiffusionImageFilter.h"
48 class WSegmentationAlgoRegionGrowingConfidenceConnected :
public WSegmentationAlgo
54 WSegmentationAlgoRegionGrowingConfidenceConnected();
59 virtual ~WSegmentationAlgoRegionGrowingConfidenceConnected();
86 template<
typename T >
102 WPropInt m_smoothingIter;
105 WPropDouble m_conductance;
108 WPropInt m_regionGrowingIterations;
111 WPropInt m_neighborhoodRadius;
114 WPropDouble m_multiplier;
117 template<
typename T >
120 typedef itk::Image< T, 3 > ImgType;
121 typedef itk::Image< double, 3 > RealType;
122 typedef itk::Image< uint64_t, 3 > LabelType;
123 typedef itk::Image< float, 3 > FinalType;
125 typedef itk::GradientAnisotropicDiffusionImageFilter< ImgType, RealType > SmoothingType;
126 typedef itk::CastImageFilter< LabelType, FinalType > CastFilter;
127 typedef itk::ConfidenceConnectedImageFilter< RealType, LabelType > RegionGrowingFilter;
129 typename ImgType::Pointer image = makeImageFromDataSet< T >( m_dataSet );
130 typename SmoothingType::Pointer smoothing = SmoothingType::New();
131 typename CastFilter::Pointer cast = CastFilter::New();
132 typename RegionGrowingFilter::Pointer regionGrowing = RegionGrowingFilter::New();
140 while( !box && k < rois.size() )
142 box =
dynamic_cast< WROIBox*
>( rois[ k ].get() );
148 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >( m_dataSet->getGrid() );
152 i[ 0 ] =
static_cast< int32_t
>( voxel[ 0 ] );
153 i[ 1 ] =
static_cast< int32_t
>( voxel[ 1 ] );
154 i[ 2 ] =
static_cast< int32_t
>( voxel[ 2 ] );
156 smoothing->SetNumberOfIterations( m_smoothingIter->get(
true ) );
157 smoothing->SetTimeStep( 0.0625 );
158 smoothing->SetConductanceParameter( m_conductance->get(
true ) );
159 smoothing->SetInput( image );
160 regionGrowing->SetInput( smoothing->GetOutput() );
161 regionGrowing->SetMultiplier( m_multiplier->get(
true ) );
162 regionGrowing->SetNumberOfIterations( m_regionGrowingIterations->get(
true ) );
163 regionGrowing->SetReplaceValue( 255.0f );
164 regionGrowing->SetInitialNeighborhoodRadius( m_neighborhoodRadius->get(
true ) );
165 regionGrowing->SetSeed( i );
166 cast->SetInput( regionGrowing->GetOutput() );
173 throw WException(
"Problem in Region Growing Segmentation" );
175 return makeDataSetFromImage< float >( cast->GetOutput() );
static WKernel * getRunningKernel()
Returns pointer to the currently running kernel.
std::shared_ptr< WROIManager > getRoiManager()
get for roi manager
A box representing a region of interest.
WPosition getMinPos() const
Get the corner of the box that has minimal x, y and z values.
WPosition getMaxPos() const
Get the corner of the box that has maximal x, y and z values.
A base class for segmentation alorithms.
virtual void properties()=0
Initialize your algorithms properties here.
virtual std::string getName()=0
Return the name of this algorithm.
std::shared_ptr< WDataSetScalar > DataSetPtr
A conveniant typedef.
virtual DataSetPtr applyOperation()=0
A virtual function that calls the correct segmentation operation.
virtual bool propChanged()=0
Checks if any properties were changed.
virtual std::string getDescription()=0
Return a description of this algorithm.
Base Class for all value set types.
Base class for all higher level values like tensors, vectors, matrices and so on.