]> Creatis software - clitk.git/commitdiff
cosmetic
authordsarrut <dsarrut>
Tue, 22 Feb 2011 07:12:45 +0000 (07:12 +0000)
committerdsarrut <dsarrut>
Tue, 22 Feb 2011 07:12:45 +0000 (07:12 +0000)
itk/clitkSliceBySliceRelativePositionFilter.h
itk/clitkSliceBySliceRelativePositionFilter.txx

index e17a759b52fb810095fcc8ef3ee494c590e0ad82..4a3ebda53998ae7212b7b3c432dcc01700e6c7f5 100644 (file)
@@ -73,53 +73,19 @@ namespace clitk {
     void PrintOptions();
     itkGetConstMacro(Direction, int);
     itkSetMacro(Direction, int);
-    // itkGetConstMacro(ObjectBackgroundValue, PixelType);
-    // itkSetMacro(ObjectBackgroundValue, PixelType);
-
-    // itkSetMacro(OrientationTypeString, std::string);
-    // itkGetConstMacro(OrientationTypeString, std::string);
-
-    // itkGetConstMacro(ResampleBeforeRelativePositionFilter, bool);
-    // itkSetMacro(ResampleBeforeRelativePositionFilter, bool);
-    // itkBooleanMacro(ResampleBeforeRelativePositionFilter);
-
-    // itkGetConstMacro(IntermediateSpacing, double);
-    // itkSetMacro(IntermediateSpacing, double);
-
-    // itkGetConstMacro(FuzzyThreshold, double);
-    // itkSetMacro(FuzzyThreshold, double);
 
     itkGetConstMacro(UniqueConnectedComponentBySlice, bool);
     itkSetMacro(UniqueConnectedComponentBySlice, bool);
     itkBooleanMacro(UniqueConnectedComponentBySlice);
 
-    // itkGetConstMacro(AutoCropFlag, bool);
-    // itkSetMacro(AutoCropFlag, bool);
-    // itkBooleanMacro(AutoCropFlag);
-
-    // itkGetConstMacro(InverseOrientationFlag, bool);
-    // itkSetMacro(InverseOrientationFlag, bool);
-    // itkBooleanMacro(InverseOrientationFlag);
-
-    // itkGetConstMacro(RemoveObjectFlag, bool);
-    // itkSetMacro(RemoveObjectFlag, bool);
-    // itkBooleanMacro(RemoveObjectFlag);
-
-    // itkGetConstMacro(CombineWithOrFlag, bool);
-    // itkSetMacro(CombineWithOrFlag, bool);
-    // itkBooleanMacro(CombineWithOrFlag);
+    itkGetConstMacro(IgnoreEmptySliceObject, bool);
+    itkSetMacro(IgnoreEmptySliceObject, bool);
+    itkBooleanMacro(IgnoreEmptySliceObject);
 
   protected:
     SliceBySliceRelativePositionFilter();
     virtual ~SliceBySliceRelativePositionFilter() {}
     
-    // PixelType m_ObjectBackgroundValue;
-    // OrientationTypeEnumeration m_OrientationType;
-    // std::string m_OrientationTypeString;
-    // double m_IntermediateSpacing;
-    // double m_FuzzyThreshold;
-    // bool m_ResampleBeforeRelativePositionFilter;
-
     virtual void GenerateOutputInformation();
     virtual void GenerateInputRequestedRegion();
     virtual void GenerateData();
@@ -130,10 +96,7 @@ namespace clitk {
     ImagePointer m_working_object;
     bool         m_UniqueConnectedComponentBySlice;
     int          m_Direction;
-    // bool m_InverseOrientationFlag;
-    // bool m_RemoveObjectFlag;
-    // bool m_AutoCropFlag;
-    // bool m_CombineWithOrFlag;
+    bool         m_IgnoreEmptySliceObject;
 
   private:
     SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented
index 36564cc945d9666ed672d088aceee39d6cdf59a7..e3801024bf389f93a0188ae367afb6ae168107a7 100644 (file)
@@ -32,6 +32,7 @@ SliceBySliceRelativePositionFilter():
 {
   SetDirection(2);
   UniqueConnectedComponentBySliceOff();
+  SetIgnoreEmptySliceObject(false);
 }
 //--------------------------------------------------------------------
 
@@ -128,8 +129,8 @@ GenerateOutputInformation()
   if (!clitk::HaveSameSizeAndSpacing<ImageType, ImageType>(m_working_object, input)) {
     this->StartNewStep("Pad object to the same size than input");
     m_working_object = clitk::ResizeImageLike<ImageType>(m_working_object, 
-                                                          input, 
-                                                          this->GetObjectBackgroundValue());
+                                                         input, 
+                                                         this->GetObjectBackgroundValue());
     this->template StopCurrentStep<ImageType>(m_working_object);
   }
   else {
@@ -172,38 +173,41 @@ GenerateOutputInformation()
   this->StartNewStep("Perform slice by slice relative position");
   for(unsigned int i=0; i<mInputSlices.size(); i++) {
     // Select main CC in each object slice (required ?)
-    mObjectSlices[i] = Labelize<SliceType>(mObjectSlices[i], 0, true, 1);
-    mObjectSlices[i] = KeepLabels<SliceType>(mObjectSlices[i], 0, 1, 1, 1, true);
-
-    // Relative position
-    typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;
-    typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
-    relPosFilter->VerboseStepFlagOff();
-    relPosFilter->WriteStepFlagOff();
-    relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId());
-    relPosFilter->SetBackgroundValue(this->GetBackgroundValue());
-    relPosFilter->SetInput(mInputSlices[i]); 
-    relPosFilter->SetInputObject(mObjectSlices[i]); 
-    relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag());
-    for(int j=0; j<this->GetNumberOfAngles(); j++) {
-      relPosFilter->AddOrientationTypeString(this->GetOrientationTypeString(j));
-    }
-    relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag());
-    //relPosFilter->SetOrientationType(this->GetOrientationType());
-    relPosFilter->SetIntermediateSpacing(this->GetIntermediateSpacing());
-    relPosFilter->SetResampleBeforeRelativePositionFilter(this->GetResampleBeforeRelativePositionFilter());
-    relPosFilter->SetFuzzyThreshold(this->GetFuzzyThreshold());
-    relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
-    relPosFilter->SetCombineWithOrFlag(this->GetCombineWithOrFlag()); 
-    relPosFilter->Update();
-    mInputSlices[i] = relPosFilter->GetOutput();
-
-    // Select main CC if needed
-    if (GetUniqueConnectedComponentBySlice()) {
-      mInputSlices[i] = Labelize<SliceType>(mInputSlices[i], 0, true, 1);
-      mInputSlices[i] = KeepLabels<SliceType>(mInputSlices[i], 0, 1, 1, 1, true);
-    }
+    int nb=0;
+    mObjectSlices[i] = LabelizeAndCountNumberOfObjects<SliceType>(mObjectSlices[i], 0, true, 1, nb);
+    if ((!GetIgnoreEmptySliceObject()) || (nb!=0)) {
+      mObjectSlices[i] = KeepLabels<SliceType>(mObjectSlices[i], 0, 1, 1, 1, true);
+
+      // Relative position
+      typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;
+      typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
+      relPosFilter->VerboseStepFlagOff();
+      relPosFilter->WriteStepFlagOff();
+      relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId());
+      relPosFilter->SetBackgroundValue(this->GetBackgroundValue());
+      relPosFilter->SetInput(mInputSlices[i]); 
+      relPosFilter->SetInputObject(mObjectSlices[i]); 
+      relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag());
+      for(int j=0; j<this->GetNumberOfAngles(); j++) {
+        relPosFilter->AddOrientationTypeString(this->GetOrientationTypeString(j));
+      }
+      relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag());
+      //relPosFilter->SetOrientationType(this->GetOrientationType());
+      relPosFilter->SetIntermediateSpacing(this->GetIntermediateSpacing());
+      relPosFilter->SetResampleBeforeRelativePositionFilter(this->GetResampleBeforeRelativePositionFilter());
+      relPosFilter->SetFuzzyThreshold(this->GetFuzzyThreshold());
+      relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
+      relPosFilter->SetCombineWithOrFlag(this->GetCombineWithOrFlag()); 
+      relPosFilter->Update();
+      mInputSlices[i] = relPosFilter->GetOutput();
+
+      // Select main CC if needed
+      if (GetUniqueConnectedComponentBySlice()) {
+        mInputSlices[i] = Labelize<SliceType>(mInputSlices[i], 0, true, 1);
+        mInputSlices[i] = KeepLabels<SliceType>(mInputSlices[i], 0, 1, 1, 1, true);
+      }
 
+    }
   }
 
   // Join the slices