X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSegmentationUtils.h;h=5ac8c4c51e86c2d7b5345fcefda25ea8ba8b3ec0;hb=ad4ece7dc0107e7ed2dfff895321a02f5051bce9;hp=532abd7009a87f836f33d5f677b3cb9a01e5373c;hpb=cbc17503754431d6529addee9e37ef955e88fd68;p=clitk.git diff --git a/itk/clitkSegmentationUtils.h b/itk/clitkSegmentationUtils.h index 532abd7..5ac8c4c 100644 --- a/itk/clitkSegmentationUtils.h +++ b/itk/clitkSegmentationUtils.h @@ -23,10 +23,12 @@ #include "clitkCommon.h" #include "clitkAutoCropFilter.h" #include "clitkLabelizeParameters.h" +#include "clitkExtractSliceFilter.h" // itk #include #include +#include /* According to @@ -37,25 +39,6 @@ namespace clitk { //-------------------------------------------------------------------- - template - void ComputeBBFromImageRegion(const ImageType * image, - typename ImageType::RegionType region, - typename itk::BoundingBox::Pointer bb); - - //-------------------------------------------------------------------- - template - void ComputeBBIntersection(typename itk::BoundingBox::Pointer bbo, - typename itk::BoundingBox::Pointer bbi1, - typename itk::BoundingBox::Pointer bbi2); - - //-------------------------------------------------------------------- - template - void ComputeRegionFromBB(const ImageType * image, - const typename itk::BoundingBox::Pointer bb, - typename ImageType::RegionType & region); - //-------------------------------------------------------------------- template typename TInternalImageType::Pointer SetBackground(const TInternalImageType * input, @@ -102,11 +85,13 @@ namespace clitk { template typename ImageType::Pointer AutoCrop(const ImageType * input, - typename ImageType::PixelType BG) { + typename ImageType::PixelType BG, + const bool useBorderFlag=false) { typedef clitk::AutoCropFilter AutoCropFilterType; typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New(); autoCropFilter->SetInput(input); autoCropFilter->SetBackgroundValue(BG); + autoCropFilter->SetUseBorder(useBorderFlag); autoCropFilter->Update(); return autoCropFilter->GetOutput(); } @@ -135,13 +120,6 @@ namespace clitk { int minimalComponentSize, LabelizeParameters * param); - //-------------------------------------------------------------------- - template - typename ImageType::Pointer - ResizeImageLike(const ImageType * input, - const itk::ImageBase * like, - typename ImageType::PixelType BG); - //-------------------------------------------------------------------- template @@ -155,6 +133,18 @@ namespace clitk { double spacing=-1, bool autocropflag=true, bool singleObjectCCL=true); + template + typename MaskImageType::Pointer + SliceBySliceRelativePosition(const MaskImageType * input, + const MaskImageType * object, + int direction, + double threshold, + double angle, + bool inverseflag, + bool uniqueConnectedComponent=false, + double spacing=-1, + bool autocropflag=true, + bool singleObjectCCL=true); //-------------------------------------------------------------------- // In a binary image, search for the point belonging to the FG that @@ -204,6 +194,11 @@ namespace clitk { //-------------------------------------------------------------------- + template + typename itk::LabelMap< itk::ShapeLabelObject >::Pointer + ComputeLabelMap(const ImageType * image, + typename ImageType::PixelType BG, + bool computePerimeterFlag=false); template void ComputeCentroids(const ImageType * image, @@ -220,9 +215,19 @@ namespace clitk { //-------------------------------------------------------------------- template void - ExtractSlices(const ImageType * image, int dim, - std::vector< typename itk::Image::Pointer > & slices); + ExtractSlices(const ImageType * image, int direction, + std::vector::Pointer > & slices) + { + typedef ExtractSliceFilter ExtractSliceFilterType; + typedef typename ExtractSliceFilterType::SliceType SliceType; + typename ExtractSliceFilterType::Pointer + extractSliceFilter = ExtractSliceFilterType::New(); + extractSliceFilter->SetInput(image); + extractSliceFilter->SetDirection(direction); + extractSliceFilter->Update(); + extractSliceFilter->GetOutputSlices(slices); + } //-------------------------------------------------------------------- @@ -231,7 +236,7 @@ namespace clitk { typename ImageType::Pointer JoinSlices(std::vector::Pointer > & slices, - const ImageType * input, + const itk::ImageBase * input, //const ImageType * input, int direction) { typedef typename itk::Image SliceType; typedef itk::JoinSeriesImageFilter JoinSeriesFilterType; @@ -308,6 +313,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, @@ -325,7 +339,16 @@ namespace clitk { std::vector & lB, typename ImageType::PixelType BG, int mainDirection, - double offsetToKeep); + double offsetToKeep, + bool keepIfEqual=false); + template + void + SliceBySliceSetBackgroundFromLineSeparation_pt(ImageType * input, + std::vector & lA, + std::vector & lB, + typename ImageType::PixelType BG, + typename ImageType::PointType offsetToKeep, + bool keepIfEqual=false); //-------------------------------------------------------------------- @@ -334,6 +357,14 @@ namespace clitk { void AndNot(ImageType * input, const ImageType * object, typename ImageType::PixelType BG=0); + template + void And(ImageType * input, + const ImageType * object, + typename ImageType::PixelType BG=0); + template + void Or(ImageType * input, + const ImageType * object, + typename ImageType::PixelType BG=0); //-------------------------------------------------------------------- @@ -386,10 +417,95 @@ namespace clitk { double margin, std::vector & A, std::vector & B); + template + void + SliceBySliceBuildLineSegmentAccordingToMinimalDistanceBetweenStructures(const ImageType * S1, + const ImageType * S2, + typename ImageType::PixelType BG, + int sliceDimension, + std::vector & A, + std::vector & B); //-------------------------------------------------------------------- -} + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + SliceBySliceKeepMainCCL(const ImageType * input, + typename ImageType::PixelType BG, + typename ImageType::PixelType FG); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + Clone(const ImageType * input); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + SliceBySliceSetBackgroundFromSingleLine(const ImageType * input, + typename ImageType::PixelType BG, + typename ImageType::PointType & A, + typename ImageType::PointType & B, + int dim1, int dim2, bool removeLowerPartFlag); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + SliceBySliceSetBackgroundFromPoints(const ImageType * input, + typename ImageType::PixelType BG, + int sliceDim, + std::vector & A, + bool removeGreaterThanXFlag, + bool removeGreaterThanYFlag); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + void + FillRegionWithValue(ImageType * input, typename ImageType::PixelType value, + typename ImageType::RegionType & region); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + void + GetMinMaxBoundary(ImageType * input, typename ImageType::PointType & min, + typename ImageType::PointType & max); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + typename itk::Image::Pointer//void + DistanceMap(const ImageType * input, typename ImageType::PixelType BG);//, + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + typename ImageType::PointType + ComputeClosestPoint(const ImageType * input, + const itk::Image * dmap, + typename ImageType::PixelType & BG); + //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + RemoveNegativeIndexFromRegion(ImageType * input); + //-------------------------------------------------------------------- + + +} // end clitk namespace #include "clitkSegmentationUtils.txx"