//--------------------------------------------------------------------
+ template<class ImageType, class LabelType>
+ typename itk::LabelMap< itk::ShapeLabelObject<LabelType, ImageType::ImageDimension> >::Pointer
+ ComputeLabelMap(const ImageType * image,
+ typename ImageType::PixelType BG,
+ bool computePerimeterFlag=false);
template<class ImageType>
void
ComputeCentroids(const ImageType * image,
//--------------------------------------------------------------------
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ Clone(const ImageType * input);
+ //--------------------------------------------------------------------
+
+
}
#include "clitkSegmentationUtils.txx"
#include <itkConstantPadImageFilter.h>
#include <itkImageSliceIteratorWithIndex.h>
#include <itkBinaryMorphologicalOpeningImageFilter.h>
+#include <itkImageDuplicator.h>
namespace clitk {
//--------------------------------------------------------------------
+ //--------------------------------------------------------------------
+ template<class ImageType, class LabelType>
+ typename itk::LabelMap< itk::ShapeLabelObject<LabelType, ImageType::ImageDimension> >::Pointer
+ ComputeLabelMap(const ImageType * image,
+ typename ImageType::PixelType BG,
+ bool computePerimeterFlag)
+ {
+ static const unsigned int Dim = ImageType::ImageDimension;
+ typedef itk::ShapeLabelObject< LabelType, Dim > LabelObjectType;
+ typedef itk::LabelMap< LabelObjectType > LabelMapType;
+ typedef itk::LabelImageToLabelMapFilter<ImageType, LabelMapType> ImageToMapFilterType;
+ typename ImageToMapFilterType::Pointer imageToLabelFilter = ImageToMapFilterType::New();
+ typedef itk::ShapeLabelMapFilter<LabelMapType, ImageType> ShapeFilterType;
+ typename ShapeFilterType::Pointer statFilter = ShapeFilterType::New();
+ imageToLabelFilter->SetBackgroundValue(BG);
+ imageToLabelFilter->SetInput(image);
+ statFilter->SetInput(imageToLabelFilter->GetOutput());
+ statFilter->SetComputePerimeter(computePerimeterFlag);
+ statFilter->Update();
+ return statFilter->GetOutput();
+ }
+ //--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
template<class ImageType>
void
//--------------------------------------------------------------------
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ Clone(const ImageType * input) {
+ typedef itk::ImageDuplicator<ImageType> DuplicatorType;
+ typename DuplicatorType::Pointer duplicator = DuplicatorType::New();
+ duplicator->SetInputImage(input);
+ duplicator->Update();
+ return duplicator->GetOutput();
+ }
+ //--------------------------------------------------------------------
+
+
} // end of namespace