]> Creatis software - clitk.git/commitdiff
simplified image pointer (const/non const)
authordsarrut <dsarrut>
Fri, 22 Oct 2010 07:34:46 +0000 (07:34 +0000)
committerdsarrut <dsarrut>
Fri, 22 Oct 2010 07:34:46 +0000 (07:34 +0000)
itk/clitkSegmentationUtils.h
itk/clitkSegmentationUtils.txx

index 80d4e93eab56cbd3ce7da2ccf8c929f1c519ad48..6959883a98b38e946ffff01928ace77fa29c2652 100644 (file)
@@ -48,27 +48,12 @@ 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>
index e031079bfcb505f6c5a210869d27917a06a85801..aef202f00ec849a3cb6e3428b59680c339864135 100644 (file)
@@ -36,7 +36,7 @@ void clitk::ComputeBBFromImageRegion(typename ImageType::Pointer image,
   IndexType lastIndex;
   for(unsigned int i=0; i<image->GetImageDimension(); i++) {
     firstIndex[i] = region.GetIndex()[i];
-    lastIndex[i] = region.GetSize()[i];
+    lastIndex[i] = firstIndex[i]+region.GetSize()[i];
   }
 
   typedef itk::BoundingBox<unsigned long, 
@@ -99,7 +99,11 @@ void clitk::ComputeRegionFromBB(typename ImageType::Pointer image,
   PointType maxs = bb->GetMaximum();
   PointType mins = bb->GetMinimum();
   for(unsigned int i=0; i<ImageType::ImageDimension; i++) {
-    regionSize[i] = floor((maxs[i] - mins[i])/image->GetSpacing()[i]);
+    // DD(maxs[i]);
+    // DD(mins[i]);
+    // DD((maxs[i] - mins[i])/image->GetSpacing()[i]);
+    regionSize[i] = lrint((maxs[i] - mins[i])/image->GetSpacing()[i]);
+    // DD(regionSize[i]);
   }
    
   // Create region
@@ -111,8 +115,9 @@ void clitk::ComputeRegionFromBB(typename ImageType::Pointer image,
 //--------------------------------------------------------------------
 template<class ImageType, class TMaskImageType>
 typename ImageType::Pointer
-clitk::SetBackground(typename ImageType::ConstPointer input, 
-                     typename TMaskImageType::ConstPointer mask, 
+clitk::SetBackground(//typename ImageType::ConstPointer input, 
+                     const ImageType * input, 
+                     const TMaskImageType * mask, 
                      typename TMaskImageType::PixelType maskBG,
                      typename ImageType::PixelType outValue) {
   typedef clitk::SetBackgroundImageFilter<ImageType, TMaskImageType, ImageType> SetBackgroundImageFilterType;
@@ -152,15 +157,18 @@ clitk::Labelize(typename ImageType::Pointer input,
                 typename ImageType::PixelType BG, 
                 bool isFullyConnected, 
                 int minimalComponentSize) {
+  // InternalImageType for storing large number of component
+  typedef itk::Image<int, ImageType::ImageDimension> InternalImageType;
+  
   // Connected Component label 
-  typedef itk::ConnectedComponentImageFilter<ImageType, ImageType> ConnectFilterType;
+  typedef itk::ConnectedComponentImageFilter<ImageType, InternalImageType> ConnectFilterType;
   typename ConnectFilterType::Pointer connectFilter = ConnectFilterType::New();
   connectFilter->SetInput(input);
   connectFilter->SetBackgroundValue(BG);
   connectFilter->SetFullyConnected(isFullyConnected);
   
   // Sort by size and remove too small area.
-  typedef itk::RelabelComponentImageFilter<ImageType, ImageType> RelabelFilterType;
+  typedef itk::RelabelComponentImageFilter<InternalImageType, ImageType> RelabelFilterType;
   typename RelabelFilterType::Pointer relabelFilter = RelabelFilterType::New();
   relabelFilter->InPlaceOn();
   relabelFilter->SetInput(connectFilter->GetOutput());