]> Creatis software - clitk.git/blobdiff - itk/clitkSegmentationUtils.h
add option to display memory usage if statgrab is installed
[clitk.git] / itk / clitkSegmentationUtils.h
index 09b0844a7271f36cb071da0cf6f542ea097eec06..3b388cba025d1bad9b1a5e40215cab91d6ffb86c 100644 (file)
 #ifndef CLITKSEGMENTATIONUTILS_H
 #define CLITKSEGMENTATIONUTILS_H
 
+// clitk
 #include "clitkCommon.h"
 #include "clitkAutoCropFilter.h"
 #include "clitkLabelizeParameters.h"
+
+// itk
 #include <itkBoundingBox.h>
 
 namespace clitk {
@@ -31,7 +34,7 @@ namespace clitk {
   void ComputeBBFromImageRegion(typename ImageType::Pointer image, 
                                 typename ImageType::RegionType region,
                                 typename itk::BoundingBox<unsigned long, 
-                                ImageType::ImageDimension>::Pointer bb);
+                                                          ImageType::ImageDimension>::Pointer bb);
   
   //--------------------------------------------------------------------
   template<int Dimension>
@@ -48,32 +51,25 @@ namespace clitk {
   //--------------------------------------------------------------------
   template<class TInternalImageType, class TMaskInternalImageType>
   typename TInternalImageType::Pointer
-  SetBackground(typename TInternalImageType::ConstPointer input,
-                typename TMaskInternalImageType::ConstPointer mask, 
+  SetBackground(const TInternalImageType * input,
+                const TMaskInternalImageType * mask, 
                 typename TMaskInternalImageType::PixelType maskBG, 
                 typename TInternalImageType::PixelType outValue);
   //--------------------------------------------------------------------
 
-    
+
   //--------------------------------------------------------------------
-  template<class TInternalImageType, class TMaskInternalImageType>
-  typename TInternalImageType::Pointer
-  SetBackground(typename TInternalImageType::Pointer input, 
-                typename TMaskInternalImageType::Pointer mask, 
-                typename TMaskInternalImageType::PixelType maskBG, 
-                typename TInternalImageType::PixelType outValue) {
-    return SetBackground<TInternalImageType, TMaskInternalImageType>
-      (static_cast<typename TInternalImageType::ConstPointer>(input),  
-       static_cast<typename TMaskInternalImageType::ConstPointer>(mask), 
-       maskBG, outValue);
-  }
+  template<class ImageType>
+  int GetNumberOfConnectedComponentLabels(typename ImageType::Pointer input, 
+                                          typename ImageType::PixelType BG, 
+                                          bool isFullyConnected);
   //--------------------------------------------------------------------
 
 
   //-------------------------------------------------------------------- 
   template<class TImageType>
   typename TImageType::Pointer
-  Labelize(typename TImageType::Pointer input, 
+  Labelize(const TImageType * input, 
            typename TImageType::PixelType BG, 
            bool isFullyConnected, 
            int minimalComponentSize);
@@ -91,23 +87,23 @@ namespace clitk {
 
   //--------------------------------------------------------------------
   template<class ImageType>
-    typename ImageType::Pointer
-    AutoCrop(typename ImageType::Pointer input, 
-            typename ImageType::PixelType BG) {
-      typedef clitk::AutoCropFilter<ImageType> AutoCropFilterType;
-      typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New();
-      autoCropFilter->SetInput(input);
-      autoCropFilter->Update();   
-      return autoCropFilter->GetOutput();
+  typename ImageType::Pointer
+  AutoCrop(typename ImageType::Pointer input, 
+           typename ImageType::PixelType BG) {
+    typedef clitk::AutoCropFilter<ImageType> AutoCropFilterType;
+    typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New();
+    autoCropFilter->SetInput(input);
+    autoCropFilter->SetBackgroundValue(BG);
+    autoCropFilter->Update();   
+    return autoCropFilter->GetOutput();
   }
-
   //--------------------------------------------------------------------
 
 
   //--------------------------------------------------------------------
   template<class TImageType>
   typename TImageType::Pointer
-  KeepLabels(typename TImageType::Pointer input,
+  KeepLabels(const TImageType * input,
              typename TImageType::PixelType BG, 
              typename TImageType::PixelType FG,  
              typename TImageType::PixelType firstKeep, 
@@ -129,10 +125,48 @@ namespace clitk {
   //--------------------------------------------------------------------
   template<class ImageType>
   typename ImageType::Pointer
-  EnlargeImageLike(typename ImageType::Pointer input,
-                   typename ImageType::Pointer like, 
-                   typename ImageType::PixelType BG);
+  ResizeImageLike(typename ImageType::Pointer input,
+                  typename ImageType::Pointer like, 
+                  typename ImageType::PixelType BG);
+
 
+  //--------------------------------------------------------------------
+  template<class MaskImageType>
+  typename MaskImageType::Pointer
+  SliceBySliceRelativePosition(const MaskImageType * input,
+                              const MaskImageType * object,
+                              int direction, 
+                              double threshold, 
+                              std::string orientation, 
+                               bool uniqueConnectedComponent=false, 
+                               double spacing=-1, 
+                              bool notflag=false);
+
+  //--------------------------------------------------------------------
+  // 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);
+
+  //--------------------------------------------------------------------
+
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  typename ImageType::Pointer
+  CropImageAlongOneAxis(typename ImageType::Pointer image, 
+                        int dim, double min, double max, 
+                        bool autoCrop = false,
+                        typename ImageType::PixelType BG=0);
+  //--------------------------------------------------------------------
 }
 
 #include "clitkSegmentationUtils.txx"