From d33a6ba9f6e2bc8c665decce8267e5b6b925e289 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Mon, 26 Sep 2011 09:03:33 +0200 Subject: [PATCH] Change "UseASingleObjectConnectedComponentBySlice" by "UseTheLargestObjectCCL" --- itk/clitkSliceBySliceRelativePositionFilter.h | 46 +++++++++---------- ...litkSliceBySliceRelativePositionFilter.txx | 38 +++++++++------ 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/itk/clitkSliceBySliceRelativePositionFilter.h b/itk/clitkSliceBySliceRelativePositionFilter.h index 53c5a87..f860c03 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.h +++ b/itk/clitkSliceBySliceRelativePositionFilter.h @@ -74,28 +74,28 @@ namespace clitk { itkGetConstMacro(Direction, int); itkSetMacro(Direction, int); - itkGetConstMacro(UniqueConnectedComponentBySlice, bool); - itkSetMacro(UniqueConnectedComponentBySlice, bool); - itkBooleanMacro(UniqueConnectedComponentBySlice); + itkGetConstMacro(UniqueConnectedComponentBySliceFlag, bool); + itkSetMacro(UniqueConnectedComponentBySliceFlag, bool); + itkBooleanMacro(UniqueConnectedComponentBySliceFlag); itkGetConstMacro(IgnoreEmptySliceObjectFlag, bool); itkSetMacro(IgnoreEmptySliceObjectFlag, bool); itkBooleanMacro(IgnoreEmptySliceObjectFlag); - itkGetConstMacro(UseASingleObjectConnectedComponentBySliceFlag, bool); - itkSetMacro(UseASingleObjectConnectedComponentBySliceFlag, bool); - itkBooleanMacro(UseASingleObjectConnectedComponentBySliceFlag); - - itkGetConstMacro(CCLSelectionFlag, bool); - itkSetMacro(CCLSelectionFlag, bool); - itkBooleanMacro(CCLSelectionFlag); - itkGetConstMacro(CCLSelectionDimension, int); - itkSetMacro(CCLSelectionDimension, int); - itkGetConstMacro(CCLSelectionDirection, int); - itkSetMacro(CCLSelectionDirection, int); - itkGetConstMacro(CCLSelectionIgnoreSingleCCLFlag, bool); - itkSetMacro(CCLSelectionIgnoreSingleCCLFlag, bool); - itkBooleanMacro(CCLSelectionIgnoreSingleCCLFlag); + itkGetConstMacro(UseTheLargestObjectCCLFlag, bool); + itkSetMacro(UseTheLargestObjectCCLFlag, bool); + itkBooleanMacro(UseTheLargestObjectCCLFlag); + + itkGetConstMacro(ObjectCCLSelectionFlag, bool); + itkSetMacro(ObjectCCLSelectionFlag, bool); + itkBooleanMacro(ObjectCCLSelectionFlag); + itkGetConstMacro(ObjectCCLSelectionDimension, int); + itkSetMacro(ObjectCCLSelectionDimension, int); + itkGetConstMacro(ObjectCCLSelectionDirection, int); + itkSetMacro(ObjectCCLSelectionDirection, int); + itkGetConstMacro(ObjectCCLSelectionIgnoreSingleCCLFlag, bool); + itkSetMacro(ObjectCCLSelectionIgnoreSingleCCLFlag, bool); + itkBooleanMacro(ObjectCCLSelectionIgnoreSingleCCLFlag); protected: SliceBySliceRelativePositionFilter(); @@ -109,14 +109,14 @@ namespace clitk { ImagePointer object; ImagePointer m_working_input; ImagePointer m_working_object; - bool m_UniqueConnectedComponentBySlice; + bool m_UniqueConnectedComponentBySliceFlag; int m_Direction; bool m_IgnoreEmptySliceObjectFlag; - bool m_UseASingleObjectConnectedComponentBySliceFlag; - bool m_CCLSelectionFlag; - int m_CCLSelectionDimension; - int m_CCLSelectionDirection; - bool m_CCLSelectionIgnoreSingleCCLFlag; + bool m_UseTheLargestObjectCCLFlag; + bool m_ObjectCCLSelectionFlag; + int m_ObjectCCLSelectionDimension; + int m_ObjectCCLSelectionDirection; + bool m_ObjectCCLSelectionIgnoreSingleCCLFlag; private: SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index f2452d8..d75cc88 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -31,16 +31,16 @@ SliceBySliceRelativePositionFilter(): clitk::AddRelativePositionConstraintToLabelImageFilter() { SetDirection(2); - UniqueConnectedComponentBySliceOff(); + UniqueConnectedComponentBySliceFlagOff(); SetIgnoreEmptySliceObjectFlag(false); - UseASingleObjectConnectedComponentBySliceFlagOn(); + UseTheLargestObjectCCLFlagOff(); this->VerboseStepFlagOff(); this->WriteStepFlagOff(); this->SetCombineWithOrFlag(false); - CCLSelectionFlagOff(); - SetCCLSelectionDimension(0); - SetCCLSelectionDirection(1); - CCLSelectionIgnoreSingleCCLFlagOff(); + ObjectCCLSelectionFlagOff(); + SetObjectCCLSelectionDimension(0); + SetObjectCCLSelectionDirection(1); + ObjectCCLSelectionIgnoreSingleCCLFlagOff(); } //-------------------------------------------------------------------- @@ -81,11 +81,15 @@ PrintOptions() DD(this->GetIntermediateSpacingFlag()); DD(this->GetIntermediateSpacing()); DD(this->GetFuzzyThreshold()); - DD(this->GetUniqueConnectedComponentBySlice()); + DD(this->GetUniqueConnectedComponentBySliceFlag()); DD(this->GetAutoCropFlag()); DD(this->GetInverseOrientationFlag()); DD(this->GetRemoveObjectFlag()); DD(this->GetCombineWithOrFlag()); + DD(this->GetUseTheLargestObjectCCLFlag()); + DD(this->GetObjectCCLSelectionFlag()); + DD(this->GetObjectCCLSelectionDimension()); + DD(this->GetObjectCCLSelectionIgnoreSingleCCLFlag()); } //-------------------------------------------------------------------- @@ -187,23 +191,23 @@ GenerateOutputInformation() if ((!GetIgnoreEmptySliceObjectFlag()) || (nb!=0)) { // Select or not a single CCL ? - if (GetUseASingleObjectConnectedComponentBySliceFlag()) { + if (GetUseTheLargestObjectCCLFlag()) { mObjectSlices[i] = KeepLabels(mObjectSlices[i], 0, 1, 1, 1, true); } // Select a single according to a position if more than one CCL - if (GetCCLSelectionFlag()) { + if (GetObjectCCLSelectionFlag()) { // if several CCL, choose the most extrema according a direction, // if not -> should we consider this slice ? if (nb<2) { - if (GetCCLSelectionIgnoreSingleCCLFlag()) { + if (GetObjectCCLSelectionIgnoreSingleCCLFlag()) { mObjectSlices[i] = SetBackground(mObjectSlices[i], mObjectSlices[i], 1, this->GetBackgroundValue(), true); } } - int dim = GetCCLSelectionDimension(); - int direction = GetCCLSelectionDirection(); + int dim = GetObjectCCLSelectionDimension(); + int direction = GetObjectCCLSelectionDirection(); std::vector centroids; ComputeCentroids(mObjectSlices[i], this->GetBackgroundValue(), centroids); uint index=1; @@ -222,7 +226,7 @@ GenerateOutputInformation() true); } } - } // end GetCCLSelectionFlag = true + } // end GetbjectCCLSelectionFlag = true // Relative position typedef clitk::AddRelativePositionConstraintToLabelImageFilter RelPosFilterType; @@ -234,10 +238,14 @@ GenerateOutputInformation() relPosFilter->SetInput(mInputSlices[i]); relPosFilter->SetInputObject(mObjectSlices[i]); relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag()); + // This flag (InverseOrientation) *must* be set before + // AddOrientation because AddOrientation can change it. + relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag()); for(int j=0; jGetNumberOfAngles(); j++) { relPosFilter->AddOrientationTypeString(this->GetOrientationTypeString(j)); + //DD(this->GetOrientationTypeString(j)); } - relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag()); + //DD(this->GetInverseOrientationFlag()); //relPosFilter->SetOrientationType(this->GetOrientationType()); relPosFilter->SetIntermediateSpacing(this->GetIntermediateSpacing()); relPosFilter->SetIntermediateSpacingFlag(this->GetIntermediateSpacingFlag()); @@ -248,7 +256,7 @@ GenerateOutputInformation() mInputSlices[i] = relPosFilter->GetOutput(); // Select main CC if needed - if (GetUniqueConnectedComponentBySlice()) { + if (GetUniqueConnectedComponentBySliceFlag()) { mInputSlices[i] = Labelize(mInputSlices[i], 0, true, 1); mInputSlices[i] = KeepLabels(mInputSlices[i], 0, 1, 1, 1, true); } -- 2.47.1