]> Creatis software - clitk.git/commitdiff
Add object uniqueCCL flag for SliceBySliceRelativePosition
authordsarrut <dsarrut>
Thu, 24 Mar 2011 07:30:49 +0000 (07:30 +0000)
committerdsarrut <dsarrut>
Thu, 24 Mar 2011 07:30:49 +0000 (07:30 +0000)
itk/clitkSegmentationUtils.h
itk/clitkSegmentationUtils.txx
itk/clitkSliceBySliceRelativePositionFilter.h
itk/clitkSliceBySliceRelativePositionFilter.txx

index 6fa67aa4ebed30d25a02b5f7faf3156948eb7eac..322f1eebe6ea71e8f62d9a107b4174b37ed2e77d 100644 (file)
@@ -152,7 +152,8 @@ namespace clitk {
                               std::string orientation, 
                                bool uniqueConnectedComponent=false, 
                                double spacing=-1, 
-                              bool notflag=false);
+                               bool autocropflag=true, 
+                               bool singleObjectCCL=true);
 
   //--------------------------------------------------------------------
   // In a binary image, search for the point belonging to the FG that
index 42ddc4759867b1231016ca847ade9c65d403068b..3da1802b601169925717ace6c3c1528cc48a802b 100644 (file)
@@ -297,7 +297,8 @@ namespace clitk {
   {
     typename ImageType::Pointer working_image;
     working_image = Labelize<ImageType>(input, BG, isFullyConnected, minimalComponentSize);
-    working_image = RemoveLabels<ImageType>(working_image, BG, param->GetLabelsToRemove());
+    if (param->GetLabelsToRemove().size() != 0)
+      working_image = RemoveLabels<ImageType>(working_image, BG, param->GetLabelsToRemove());
     working_image = KeepLabels<ImageType>(working_image, 
                                           BG, FG, 
                                           param->GetFirstKeep(), 
@@ -336,7 +337,8 @@ namespace clitk {
                                std::string orientation, 
                                bool uniqueConnectedComponent, 
                                double spacing, 
-                               bool inverseflag) 
+                               bool autocropFlag, 
+                               bool singleObjectCCL) 
   {
     typedef SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
     typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New();
@@ -350,8 +352,10 @@ namespace clitk {
     sliceRelPosFilter->SetIntermediateSpacingFlag((spacing != -1));
     sliceRelPosFilter->SetIntermediateSpacing(spacing);
     sliceRelPosFilter->SetUniqueConnectedComponentBySlice(uniqueConnectedComponent);
-    sliceRelPosFilter->SetInverseOrientationFlag(inverseflag);
-    //  sliceRelPosFilter->SetAutoCropFlag(true); ??
+    sliceRelPosFilter->SetUseASingleObjectConnectedComponentBySliceFlag(singleObjectCCL);
+    //    sliceRelPosFilter->SetInverseOrientationFlag(inverseflag); 
+    sliceRelPosFilter->SetAutoCropFlag(autocropFlag); 
+    sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn();
     sliceRelPosFilter->Update();
     return sliceRelPosFilter->GetOutput();
   }
index 0da64dc76179a67f10746f2c615d88a627a6e157..be31dfc0fab8a6a0c6bdfac458f5e93255999fdd 100644 (file)
@@ -82,6 +82,10 @@ namespace clitk {
     itkSetMacro(IgnoreEmptySliceObjectFlag, bool);
     itkBooleanMacro(IgnoreEmptySliceObjectFlag);
 
+    itkGetConstMacro(UseASingleObjectConnectedComponentBySliceFlag, bool);
+    itkSetMacro(UseASingleObjectConnectedComponentBySliceFlag, bool);
+    itkBooleanMacro(UseASingleObjectConnectedComponentBySliceFlag);
+
   protected:
     SliceBySliceRelativePositionFilter();
     virtual ~SliceBySliceRelativePositionFilter() {}
@@ -97,6 +101,7 @@ namespace clitk {
     bool         m_UniqueConnectedComponentBySlice;
     int          m_Direction;
     bool         m_IgnoreEmptySliceObjectFlag;
+    bool         m_UseASingleObjectConnectedComponentBySliceFlag;
 
   private:
     SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented
index eafb41608e3e8ae68f1e30b10360d5d96607e830..6a4b0f49ab507a089842ef723ab58f169f3ac61f 100644 (file)
@@ -33,6 +33,9 @@ SliceBySliceRelativePositionFilter():
   SetDirection(2);
   UniqueConnectedComponentBySliceOff();
   SetIgnoreEmptySliceObjectFlag(false);
+  UseASingleObjectConnectedComponentBySliceFlagOn();
+  this->VerboseStepFlagOff();
+  this->WriteStepFlagOff();
   this->SetCombineWithOrFlag(false);
 }
 //--------------------------------------------------------------------
@@ -173,11 +176,16 @@ GenerateOutputInformation()
   // Perform slice by slice relative position
   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 ?)
+    
+    // Count the number of CCL (allow to ignore empty slice)
     int nb=0;
     mObjectSlices[i] = LabelizeAndCountNumberOfObjects<SliceType>(mObjectSlices[i], 0, true, 1, nb);
     if ((!GetIgnoreEmptySliceObjectFlag()) || (nb!=0)) {
-      mObjectSlices[i] = KeepLabels<SliceType>(mObjectSlices[i], 0, 1, 1, 1, true);
+
+      // Select or not a single CCL ?
+      if (GetUseASingleObjectConnectedComponentBySliceFlag()) {
+        mObjectSlices[i] = KeepLabels<SliceType>(mObjectSlices[i], 0, 1, 1, 1, true);
+      }
 
       // Relative position
       typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;