35 #ifndef __itkChanAndVeseSegmentationFilter_h
36 #define __itkChanAndVeseSegmentationFilter_h
38 #include "itkScalarChanAndVeseSparseLevelSetImageFilter.h"
39 #include "itkScalarChanAndVeseLevelSetFunction.h"
40 #include "itkScalarChanAndVeseLevelSetFunctionData.h"
41 #include "itkConstrainedRegionBasedLevelSetFunctionSharedData.h"
42 #include "itkAtanRegularizedHeavisideStepFunction.h"
44 #include "itkFastMarchingImageFilter.h"
48 #include "itkImageFileWriter.h"
51 #include "itkRegionOfInterestImageFilter.h"
59 template<
class TFeatureImage >
116 typedef RegionOfInterestImageFilter<
120 typedef AtanRegularizedHeavisideStepFunction< InternalPixelType, InternalPixelType >
122 typedef typename DomainFunctionType::Pointer
127 typedef typename FastMarchingFilterType::NodeContainer
129 typedef typename FastMarchingFilterType::NodeType
NodeType;
186 m_Output = InternalImageType::New();
204 std::cerr <<
"m_FeatureImage is Null" << std::endl;
221 for(
unsigned int j = 0; j < Dimension; j++ )
229 for (
unsigned int j = 0; j < Dimension; j++ )
243 std::cout <<
"Spacing: " << spacing << std::endl;
244 std::cout <<
"Input Size: " << inputSize << std::endl;
245 std::cout <<
"Output Size: " <<
m_Size << std::endl;
246 std::cout <<
"Origin: " << origin << std::endl;
247 std::cout <<
"Radius: " <<
m_Radius << std::endl;
248 std::cout <<
"Center: " << cen << std::endl;
250 typename NodeContainer::Pointer seeds = NodeContainer::New();
252 seeds->InsertElement(0, node);
256 region2.SetIndex(start2);
260 image->SetRegions(region2);
274 while ( !r_it.IsAtEnd() )
276 idx = r_it.GetIndex();
278 for (
unsigned int dim = 0; dim < Dimension; dim++ )
280 d += ( idx[dim] - cen[dim] ) * ( idx[dim] - cen[dim] )
281 * spacing[dim] * spacing[dim];
283 r_it.Set(vcl_sqrt(d) - r);
294 preprocess->SetLargestCellRadius (
m_Radius);
298 preprocess->Update();
300 catch ( itk::ExceptionObject & err )
302 std::cerr <<
"preprocess Exception:" << err << std::endl;
305 feature = preprocess->GetOutput();
306 feature->SetOrigin(origin);
307 feature->DisconnectPipeline();
315 domainFunction->SetEpsilon(1.);
317 typedef std::vector< unsigned int > VectorType;
318 VectorType lookUp(1, 1);
320 image->CopyInformation(feature);
323 LevelSetFilter->SetFunctionCount(1);
324 LevelSetFilter->SetLookup(lookUp);
325 LevelSetFilter->SetFeatureImage(feature);
326 LevelSetFilter->SetLevelSet(0, image);
328 LevelSetFilter->SetMaximumRMSError(0);
329 LevelSetFilter->SetUseImageSpacing(1);
330 LevelSetFilter->SetInPlace(
false);
332 LevelSetFilter->GetDifferenceFunction(0)->SetDomainFunction(domainFunction);
333 LevelSetFilter->GetDifferenceFunction(0)->
335 LevelSetFilter->GetDifferenceFunction(0)->SetAreaWeight(0.);
336 LevelSetFilter->GetDifferenceFunction(0)->SetLambda1(1.);
337 LevelSetFilter->GetDifferenceFunction(0)->SetLambda2(1.);
340 LevelSetFilter->Update();
342 catch ( itk::ExceptionObject & err )
344 std::cerr <<
"levelsetfilter Exception:" << err << std::endl;
347 m_Output->Graft( LevelSetFilter->GetLevelSet(0) );
SmartPointer< Self > Pointer
FastMarchingImageFilter< InternalImageType, InternalImageType > FastMarchingFilterType
void operator=(const Self &)
AtanRegularizedHeavisideStepFunction< InternalPixelType, InternalPixelType > DomainFunctionType
DomainFunctionType::Pointer DomainFunctionPointer
itkGetConstMacro(Preprocess, bool)
InternalIndexType::IndexValueType InternalIndexValueType
void SetFeatureImage(FeatureImageType *iImage)
ImageRegionIteratorWithIndex< InternalImageType > InternalRegionIterator
void SetRadius(const InternalCoordRepType &iR)
FeatureImagePointer m_FeatureImage
FeatureImageType::Pointer FeatureImagePointer
ScalarChanAndVeseLevelSetFunction< InternalImageType, FeatureImageType, SharedDataHelperType > FunctionType
TFeatureImage OutputImageType
FastMarchingFilterType::NodeContainer NodeContainer
RegionOfInterestImageFilter< FeatureImageType, FeatureImageType > ROIFilterType
itk::PreprocessImageFilter< FeatureImageType, FeatureImageType > PreprocessFilterType
InternalSizeType::SizeValueType InternalSizeValueType
InternalPointType::CoordRepType InternalCoordRepType
InternalImageType::PixelType InternalPixelType
OutputImageType::Pointer OutputImagePointer
FastMarchingFilterType::NodeType NodeType
InternalImageType::SizeType InternalSizeType
~ChanAndVeseSegmentationFilter()
void SetCenter(const InternalPointType &iC)
itkTypeMacro(ChanAndVeseSegmentationFilter, Object)
FeatureImageType::SizeType FeatureSizeType
InternalImageType::RegionType InternalRegionType
ScalarChanAndVeseSparseLevelSetImageFilter< InternalImageType, FeatureImageType, OutputImageType, FunctionType, SharedDataHelperType > MultiLevelSetType
InternalCoordRepType GetRadius() const
ChanAndVeseSegmentationFilter()
itkSetMacro(Preprocess, bool)
InternalPointType GetCenter() const
ROIFilterType::Pointer ROIFilterPointer
InternalImageType::PointType InternalPointType
TFeatureImage FeatureImageType
MultiLevelSetType::Pointer MultiLevelSetPointer
InternalPointType m_Center
void SetNumberOfIterations(int iNumberOfIterations)
ScalarChanAndVeseLevelSetFunctionData< InternalImageType, FeatureImageType > DataHelperType
InternalImageType::Pointer InternalImagePointer
InternalImageType::IndexType InternalIndexType
SmartPointer< const Self > ConstPointer
itkStaticConstMacro(Dimension, unsigned int, TFeatureImage::ImageDimension)
ConstrainedRegionBasedLevelSetFunctionSharedData< InternalImageType, FeatureImageType, DataHelperType > SharedDataHelperType
InternalImagePointer m_Output
SmartPointer< Self > Pointer
InternalCoordRepType m_Radius
Image< float, Dimension > InternalImageType
PreprocessFilterType::Pointer PreprocessFilterPointer
InternalImagePointer GetOutput()
void SetCurvatureWeight(int iCurvatureWeight)
InternalImageType::SpacingType InternalSpacingType
Denoise images - remove median noise and perform morphological reconstruction. Makes it easier to seg...
FeatureImageType::SpacingType FeatureSpacingType
ChanAndVeseSegmentationFilter Self