]> Creatis software - clitk.git/commitdiff
add 'border' option
authordsarrut <dsarrut>
Tue, 15 Feb 2011 10:46:13 +0000 (10:46 +0000)
committerdsarrut <dsarrut>
Tue, 15 Feb 2011 10:46:13 +0000 (10:46 +0000)
itk/clitkAutoCropFilter.h
itk/clitkAutoCropFilter.txx

index f4f35bcc0b15b23eb53745f2d595f837c4b4a98f..94cdb656af69257298ff11684459a5a3877b0cd0 100644 (file)
@@ -58,6 +58,11 @@ namespace clitk {
     
     // LabelImage information (BG)
     void SetBackgroundValue(ImagePixelType p);
+    
+    // Use a border
+    itkSetMacro(UseBorder, bool);
+    itkGetConstMacro(UseBorder, bool);
+    itkBooleanMacro(UseBorder);
 
     /** ImageDimension constants */
     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
@@ -72,6 +77,7 @@ namespace clitk {
     ImagePixelType m_BackgroundValue;
     ImageRegionType m_Region;
     ImagePointer m_labeImage;
+    bool m_UseBorder;
     
   private:
     AutoCropFilter(const Self&); //purposely not implemented
index 8f45f575aef816f6b39be387a7af94f66d30c969..85ce7be27cc4102825a73e911fccf1c4c6dc6b6c 100644 (file)
@@ -39,6 +39,7 @@ namespace clitk {
   AutoCropFilter():itk::ImageToImageFilter<ImageType, ImageType>() {
     this->SetNumberOfRequiredInputs(1);
     m_BackgroundValue  = 0;
+    UseBorderOn();
   }
   //--------------------------------------------------------------------
 
@@ -95,8 +96,14 @@ namespace clitk {
     typedef itk::AutoCropLabelMapFilter<LabelMapType> AutoCropFilterType;
     typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New();
     autoCropFilter->SetInput(imageToLabelFilter->GetOutput());
-    autoCropFilter->ReleaseDataFlagOff(); 
-    
+    //    autoCropFilter->ReleaseDataFlagOff(); 
+    if (GetUseBorder()) {
+      typename ImageType::SizeType s;
+      for(uint i=0; i<ImageType::ImageDimension; i++) s[i] = 1;
+      autoCropFilter->SetCropBorder(s);
+    }
+    autoCropFilter->ReleaseDataFlagOn(); 
+
     // Convert to LabelImage
     typedef itk::LabelMapToLabelImageFilter<LabelMapType, ImageType> MapToImageFilterType;
     typename MapToImageFilterType::Pointer labelToImageFilter = MapToImageFilterType::New();       
@@ -114,8 +121,9 @@ namespace clitk {
       typename ImageType::IndexType index; 
       index.Fill(0);
       m_Region.SetIndex(index);
-      DD(m_Region);
     }
+
+    // Set the region to output
     output->SetLargestPossibleRegion(m_Region);
     output->SetRequestedRegion(m_Region);
     output->SetBufferedRegion(m_Region);