+ template<class ImageType>
+ typename ImageType::Pointer
+ CropImageRemoveGreaterThan(const ImageType * image,
+ int dim, double min, bool autoCrop = false,
+ typename ImageType::PixelType BG=0);
+ template<class ImageType>
+ typename ImageType::Pointer
+ CropImageRemoveLowerThan(const ImageType * image,
+ int dim, double max,bool autoCrop = false,
+ typename ImageType::PixelType BG=0);
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ 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,
+ typename ImageType::PixelType BG,
+ std::vector<typename ImageType::PointType> & centroids);
+ template<class ImageType>
+ void
+ ComputeCentroids2(const ImageType * image,
+ typename ImageType::PixelType BG,
+ std::vector<typename ImageType::PointType> & centroids);
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ void
+ ExtractSlices(const ImageType * image, int direction,
+ std::vector<typename itk::Image<typename ImageType::PixelType,
+ ImageType::ImageDimension-1>::Pointer > & slices)
+ {
+ typedef ExtractSliceFilter<ImageType> ExtractSliceFilterType;
+ typedef typename ExtractSliceFilterType::SliceType SliceType;
+ typename ExtractSliceFilterType::Pointer
+ extractSliceFilter = ExtractSliceFilterType::New();
+ extractSliceFilter->SetInput(image);
+ extractSliceFilter->SetDirection(direction);
+ extractSliceFilter->Update();
+ extractSliceFilter->GetOutputSlices(slices);
+ }
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ JoinSlices(std::vector<typename itk::Image<typename ImageType::PixelType,
+ ImageType::ImageDimension-1>::Pointer > & slices,
+ const itk::ImageBase<ImageType::ImageDimension> * input, //const ImageType * input,
+ int direction) {
+ typedef typename itk::Image<typename ImageType::PixelType, ImageType::ImageDimension-1> SliceType;
+ typedef itk::JoinSeriesImageFilter<SliceType, ImageType> JoinSeriesFilterType;
+ typename JoinSeriesFilterType::Pointer joinFilter = JoinSeriesFilterType::New();
+ joinFilter->SetOrigin(input->GetOrigin()[direction]);
+ joinFilter->SetSpacing(input->GetSpacing()[direction]);
+ for(unsigned int i=0; i<slices.size(); i++) {
+ joinFilter->PushBackInput(slices[i]);
+ }
+ joinFilter->Update();
+ return joinFilter->GetOutput();
+ }
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ // Set of tools to manage 3D points and 2D points in slices
+ template<class ImageType>
+ class PointsUtils
+ {
+ typedef typename ImageType::PointType PointType3D;
+ typedef typename ImageType::IndexType IndexType3D;
+ typedef typename ImageType::PixelType PixelType;
+ typedef typename ImageType::Pointer ImagePointer;
+ typedef typename ImageType::ConstPointer ImageConstPointer;
+ typedef itk::Image<PixelType, 2> SliceType;
+ typedef typename SliceType::PointType PointType2D;
+ typedef typename SliceType::IndexType IndexType2D;
+
+ typedef std::map<int, PointType2D> MapPoint2DType;
+ typedef std::vector<PointType3D> VectorPoint3DType;
+ typedef std::vector<PointType2D> VectorPoint2DType;
+
+ public:
+ static void Convert2DTo3D(const PointType2D & p2D,
+ const ImageType * image,
+ const int slice,
+ PointType3D & p3D);
+ static void Convert2DMapTo3DList(const MapPoint2DType & map,
+ const ImageType * image,
+ VectorPoint3DType & list);
+ static void Convert2DListTo3DList(const VectorPoint2DType & p,
+ int slice,
+ const ImageType * image,
+ VectorPoint3DType & list);
+ };
+
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ void
+ WriteListOfLandmarks(std::vector<typename ImageType::PointType> points,
+ std::string filename);
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ Dilate(const ImageType * image, double radiusInMM,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ bool extendSupport);
+ template<class ImageType>
+ typename ImageType::Pointer
+ Dilate(const ImageType * image, typename ImageType::SizeType radius,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ bool extendSupport);
+ template<class ImageType>
+ typename ImageType::Pointer
+ Dilate(const ImageType * image, typename ImageType::PointType radiusInMM,
+ typename ImageType::PixelType BG,
+ typename ImageType::PixelType FG,
+ bool extendSupport);
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ Opening(const ImageType * image, typename ImageType::SizeType radius,
+ typename ImageType::PixelType BG, typename ImageType::PixelType FG);
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ template<class ValueType, class VectorType>
+ void ConvertOption(std::string optionName, uint given,
+ ValueType * values, VectorType & p,
+ uint dim, bool required);
+#define ConvertOptionMacro(OPTIONNAME, VAR, DIM, REQUIRED) \
+ ConvertOption(#OPTIONNAME, OPTIONNAME##_given, OPTIONNAME##_arg, VAR, DIM, REQUIRED);
+ //--------------------------------------------------------------------
+
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ void
+ SliceBySliceSetBackgroundFromLineSeparation(ImageType * input,
+ std::vector<typename ImageType::PointType> & lA,
+ std::vector<typename ImageType::PointType> & lB,
+ typename ImageType::PixelType BG,
+ int mainDirection,
+ double offsetToKeep);