X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSegmentationUtils.h;h=4d7129821eabf8aeac167f0b5699dcf878e372da;hb=473cb0db7da37740926a0ec36b3f449ef27ef565;hp=6f4deb4c01726349b756449770023d7d29f2e825;hpb=8ce049c3b7fbb418f7fb106c726bc0bf37c06e12;p=clitk.git diff --git a/itk/clitkSegmentationUtils.h b/itk/clitkSegmentationUtils.h index 6f4deb4..4d71298 100644 --- a/itk/clitkSegmentationUtils.h +++ b/itk/clitkSegmentationUtils.h @@ -26,6 +26,7 @@ // itk #include +#include /* According to @@ -191,14 +192,14 @@ namespace clitk { typename ImageType::PixelType BG=0); template typename ImageType::Pointer - CropImageAbove(const ImageType * image, - int dim, double min, bool autoCrop = false, - typename ImageType::PixelType BG=0); + CropImageRemoveGreaterThan(const ImageType * image, + int dim, double min, bool autoCrop = false, + typename ImageType::PixelType BG=0); template typename ImageType::Pointer - CropImageBelow(const ImageType * image, - int dim, double max,bool autoCrop = false, - typename ImageType::PixelType BG=0); + CropImageRemoveLowerThan(const ImageType * image, + int dim, double max,bool autoCrop = false, + typename ImageType::PixelType BG=0); //-------------------------------------------------------------------- @@ -208,6 +209,11 @@ namespace clitk { ComputeCentroids(const ImageType * image, typename ImageType::PixelType BG, std::vector & centroids); + template + void + ComputeCentroids2(const ImageType * image, + typename ImageType::PixelType BG, + std::vector & centroids); //-------------------------------------------------------------------- @@ -221,11 +227,23 @@ namespace clitk { //-------------------------------------------------------------------- - //template - //typename ImageType::Pointer - //JoinSlices(std::vector::Pointer > & slices, - // const ImageType * input, int dim); + template + typename ImageType::Pointer + JoinSlices(std::vector::Pointer > & slices, + const ImageType * input, + int direction) { + typedef typename itk::Image SliceType; + typedef itk::JoinSeriesImageFilter JoinSeriesFilterType; + typename JoinSeriesFilterType::Pointer joinFilter = JoinSeriesFilterType::New(); + joinFilter->SetOrigin(input->GetOrigin()[direction]); + joinFilter->SetSpacing(input->GetSpacing()[direction]); + for(unsigned int i=0; iPushBackInput(slices[i]); + } + joinFilter->Update(); + return joinFilter->GetOutput(); + } //-------------------------------------------------------------------- @@ -245,14 +263,20 @@ namespace clitk { typedef std::map MapPoint2DType; typedef std::vector VectorPoint3DType; + typedef std::vector VectorPoint2DType; + public: static void Convert2DTo3D(const PointType2D & p2D, const ImageType * image, const int slice, PointType3D & p3D); - static void Convert2DTo3DList(const MapPoint2DType & map, + static void Convert2DMapTo3DList(const MapPoint2DType & map, const ImageType * image, VectorPoint3DType & list); + static void Convert2DListTo3DList(const VectorPoint2DType & p, + int slice, + const ImageType * image, + VectorPoint3DType & list); }; //-------------------------------------------------------------------- @@ -284,6 +308,15 @@ namespace clitk { bool extendSupport); //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + Opening(const ImageType * image, typename ImageType::SizeType radius, + typename ImageType::PixelType BG, typename ImageType::PixelType FG); + //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- template void ConvertOption(std::string optionName, uint given, @@ -349,6 +382,31 @@ namespace clitk { IsOnTheSameLineSide(PointType C, PointType A, PointType B, PointType like); //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + template + void + SliceBySliceBuildLineSegmentAccordingToExtremaPosition(const ImageType * input, + typename ImageType::PixelType BG, + int sliceDimension, + int extremaDirection, + bool extremaOppositeFlag, + int lineDirection, + double margin, + std::vector & A, + std::vector & B); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + SliceBySliceKeepMainCCL(const ImageType * input, + typename ImageType::PixelType BG, + typename ImageType::PixelType FG); + //-------------------------------------------------------------------- + + } #include "clitkSegmentationUtils.txx"