]> Creatis software - clitk.git/commitdiff
Add VerboseSlicesFlag
authorDavid Sarrut <david.sarrut@gmail.com>
Thu, 7 Jun 2012 13:48:52 +0000 (15:48 +0200)
committerDavid Sarrut <david.sarrut@gmail.com>
Thu, 7 Jun 2012 13:48:52 +0000 (15:48 +0200)
itk/clitkSliceBySliceRelativePositionFilter.h
itk/clitkSliceBySliceRelativePositionFilter.txx

index 90a1b2567e8cb4779bd8d9f21bfeeed15478b09e..ba59467f5ece21cc3b7538ba47ce40c19153297a 100644 (file)
@@ -98,6 +98,10 @@ namespace clitk {
     itkSetMacro(ObjectCCLSelectionIgnoreSingleCCLFlag, bool);
     itkBooleanMacro(ObjectCCLSelectionIgnoreSingleCCLFlag);
 
+    itkGetConstMacro(VerboseSlicesFlag, bool);
+    itkSetMacro(VerboseSlicesFlag, bool);
+    itkBooleanMacro(VerboseSlicesFlag);
+
   protected:
     SliceBySliceRelativePositionFilter();
     virtual ~SliceBySliceRelativePositionFilter() {}
@@ -118,6 +122,7 @@ namespace clitk {
     int          m_ObjectCCLSelectionDimension;
     int          m_ObjectCCLSelectionDirection;
     bool         m_ObjectCCLSelectionIgnoreSingleCCLFlag;
+    bool         m_VerboseSlicesFlag;
 
   private:
     SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented
index eff331daa9e6d99269629f4ba6f112aca2fcec96..6fceb9bb98990aee3ae5aebcef6f1a795bff522a 100644 (file)
@@ -42,6 +42,7 @@ SliceBySliceRelativePositionFilter():
   SetObjectCCLSelectionDimension(0);
   SetObjectCCLSelectionDirection(1);
   ObjectCCLSelectionIgnoreSingleCCLFlagOff();
+  VerboseSlicesFlagOff();
 }
 //--------------------------------------------------------------------
 
@@ -158,6 +159,9 @@ GenerateOutputInformation()
     this->template StopCurrentStep<ImageType>(m_working_object);
     */
 
+    DD(input->GetLargestPossibleRegion());
+    DD(m_working_object->GetLargestPossibleRegion());
+
     // Compute union of bounding boxes in X and Y
     static const unsigned int dim = ImageType::ImageDimension;
     typedef itk::BoundingBox<unsigned long, dim> BBType;
@@ -182,6 +186,11 @@ GenerateOutputInformation()
                                                          m_working_input, 
                                                          this->GetObjectBackgroundValue());
     
+    // Index can be negative in some cases, and lead to problem with
+    // some filter. So we correct it.
+    m_working_input = clitk::RemoveNegativeIndexFromRegion<ImageType>(m_working_input);
+    m_working_object = clitk::RemoveNegativeIndexFromRegion<ImageType>(m_working_object);
+
     // End
     this->template StopCurrentStep<ImageType>(m_working_input);  
   }
@@ -286,6 +295,10 @@ GenerateOutputInformation()
         typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;
         typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
         relPosFilter->VerboseStepFlagOff();
+        if (GetVerboseSlicesFlag()) {
+          std::cout << "Slice " << i << std::endl;
+          relPosFilter->VerboseStepFlagOn();
+        }
         relPosFilter->WriteStepFlagOff();
         // relPosFilter->VerboseMemoryFlagOn();
         relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId()+"-"+toString(i));