]> Creatis software - clitk.git/blobdiff - itk/clitkSegmentationUtils.h
add cache for read image
[clitk.git] / itk / clitkSegmentationUtils.h
index 3b388cba025d1bad9b1a5e40215cab91d6ffb86c..77270d1a542b4d2c1bb7bc3346bcb91967b49f2c 100644 (file)
@@ -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<class SliceType>
-  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<class ImageType>
+  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<class ImageType>
+  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<class ImageType>
+  typename ImageType::Pointer
+  CropImageAbove(typename ImageType::Pointer image, 
+                 int dim, double min, 
+                 bool autoCrop = false,
+                 typename ImageType::PixelType BG=0);
+  template<class ImageType>
+  typename ImageType::Pointer
+  CropImageBelow(typename ImageType::Pointer image, 
+                 int dim, double max,
+                 bool autoCrop = false,
+                 typename ImageType::PixelType BG=0);
+  //--------------------------------------------------------------------
+
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  void
+  ComputeCentroids(typename ImageType::Pointer image, 
+                   typename ImageType::PixelType BG, 
+                   std::vector<typename ImageType::PointType> & centroids);
+  //--------------------------------------------------------------------
+
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  void
+  ExtractSlices(typename ImageType::Pointer image, 
+               int dim, 
+               std::vector< typename itk::Image<typename ImageType::PixelType, 
+               ImageType::ImageDimension-1>::Pointer > & slices);
+  //--------------------------------------------------------------------
+
+
   //--------------------------------------------------------------------
+  template<class ImageType>
+  typename ImageType::Pointer
+  JoinSlices(std::vector<typename itk::Image<typename ImageType::PixelType, 
+            ImageType::ImageDimension-1>::Pointer > & slices, 
+            typename ImageType::Pointer input, 
+            int dim);
+  //--------------------------------------------------------------------
+
+
+  //--------------------------------------------------------------------
+  // 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::PixelType PixelType;
+    typedef typename ImageType::Pointer ImagePointer;
+    typedef typename ImageType::ConstPointer ImageConstPointer;
+    typedef itk::Image<PixelType, 2> SliceType;
+    typedef typename SliceType::PointType PointType2D;
+    
+    typedef std::map<int, PointType2D> MapPoint2DType;
+    typedef std::vector<PointType3D> 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<class ImageType>
+  void 
+  WriteListOfLandmarks(std::vector<typename ImageType::PointType> points, 
+                       std::string filename);
+  //--------------------------------------------------------------------
+
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  typename ImageType::Pointer
+  Dilate(typename ImageType::Pointer image, 
+              double radiusInMM,               
+              typename ImageType::PixelType BG, 
+              typename ImageType::PixelType FG, 
+              bool extendSupport);
+  template<class ImageType>
+  typename ImageType::Pointer
+  Dilate(typename ImageType::Pointer image, 
+              typename ImageType::SizeType radius, 
+              typename ImageType::PixelType BG, 
+              typename ImageType::PixelType FG, 
+              bool extendSupport);
+  template<class ImageType>
+  typename ImageType::Pointer  
+  Dilate(typename ImageType::Pointer image, 
+              typename ImageType::PointType radiusInMM, 
+              typename ImageType::PixelType BG, 
+              typename ImageType::PixelType FG, 
+              bool extendSupport);
+  //--------------------------------------------------------------------
+
+  //--------------------------------------------------------------------
+  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);
+
 }
 
 #include "clitkSegmentationUtils.txx"