X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSegmentationUtils.h;h=77270d1a542b4d2c1bb7bc3346bcb91967b49f2c;hb=3c1886a2789de650bebcbcbc60e454b248f83e38;hp=3b388cba025d1bad9b1a5e40215cab91d6ffb86c;hpb=be468bdd8d0ce316c0bbc71d860c9546c0d01d3b;p=clitk.git diff --git a/itk/clitkSegmentationUtils.h b/itk/clitkSegmentationUtils.h index 3b388cb..77270d1 100644 --- a/itk/clitkSegmentationUtils.h +++ b/itk/clitkSegmentationUtils.h @@ -54,7 +54,8 @@ namespace clitk { SetBackground(const TInternalImageType * input, const TMaskInternalImageType * mask, typename TMaskInternalImageType::PixelType maskBG, - typename TInternalImageType::PixelType outValue); + typename TInternalImageType::PixelType outValue, + bool inPlace); //-------------------------------------------------------------------- @@ -145,17 +146,27 @@ namespace clitk { //-------------------------------------------------------------------- // In a binary image, search for the point belonging to the FG that // is the most exterma in the direction 'direction' (or in the - // opposite if notFlag is given). if 'point' and 'distanceMax' are - // given, do not consider points that are away from 'point' more - // than 'distanceMax' - template - typename SliceType::PointType - FindExtremaPointInAGivenDirection(const SliceType * input, - typename SliceType::PixelType bg, - int direction, - bool notFlag, - typename SliceType::PointType point, - double distanceMax); + // opposite if notFlag is given). + template + bool + FindExtremaPointInAGivenDirection(const ImageType * input, + typename ImageType::PixelType bg, + int direction, bool opposite, + typename ImageType::PointType & p); + + //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + // Same as above but check that the found point is not more than + // 'distanceMax' away from 'refPoint' + template + bool + FindExtremaPointInAGivenDirection(const ImageType * input, + typename ImageType::PixelType bg, + int direction, bool opposite, + typename ImageType::PointType refPoint, + double distanceMax, + typename ImageType::PointType & p); //-------------------------------------------------------------------- @@ -166,7 +177,114 @@ namespace clitk { int dim, double min, double max, bool autoCrop = false, typename ImageType::PixelType BG=0); + template + typename ImageType::Pointer + CropImageAbove(typename ImageType::Pointer image, + int dim, double min, + bool autoCrop = false, + typename ImageType::PixelType BG=0); + template + typename ImageType::Pointer + CropImageBelow(typename ImageType::Pointer image, + int dim, double max, + bool autoCrop = false, + typename ImageType::PixelType BG=0); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + void + ComputeCentroids(typename ImageType::Pointer image, + typename ImageType::PixelType BG, + std::vector & centroids); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + void + ExtractSlices(typename ImageType::Pointer image, + int dim, + std::vector< typename itk::Image::Pointer > & slices); + //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + JoinSlices(std::vector::Pointer > & slices, + typename ImageType::Pointer input, + int dim); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + // Set of tools to manage 3D points and 2D points in slices + template + class PointsUtils + { + typedef typename ImageType::PointType PointType3D; + typedef typename ImageType::PixelType PixelType; + typedef typename ImageType::Pointer ImagePointer; + typedef typename ImageType::ConstPointer ImageConstPointer; + typedef itk::Image SliceType; + typedef typename SliceType::PointType PointType2D; + + typedef std::map MapPoint2DType; + typedef std::vector VectorPoint3DType; + public: + static void Convert2DTo3D(const PointType2D & p2D, + ImagePointer image, + const int slice, + PointType3D & p3D); + static void Convert2DTo3DList(const MapPoint2DType & map, + ImagePointer image, + VectorPoint3DType & list); + }; + + //-------------------------------------------------------------------- + template + void + WriteListOfLandmarks(std::vector points, + std::string filename); + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template + typename ImageType::Pointer + Dilate(typename ImageType::Pointer image, + double radiusInMM, + typename ImageType::PixelType BG, + typename ImageType::PixelType FG, + bool extendSupport); + template + typename ImageType::Pointer + Dilate(typename ImageType::Pointer image, + typename ImageType::SizeType radius, + typename ImageType::PixelType BG, + typename ImageType::PixelType FG, + bool extendSupport); + template + typename ImageType::Pointer + Dilate(typename ImageType::Pointer image, + typename ImageType::PointType radiusInMM, + typename ImageType::PixelType BG, + typename ImageType::PixelType FG, + bool extendSupport); + //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + template + 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); + } #include "clitkSegmentationUtils.txx"