From acce45844cc7d465d97939f42a56d81a6cf80179 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Thu, 24 Mar 2011 07:30:49 +0000 Subject: [PATCH] Add object uniqueCCL flag for SliceBySliceRelativePosition --- itk/clitkSegmentationUtils.h | 3 ++- itk/clitkSegmentationUtils.txx | 12 ++++++++---- itk/clitkSliceBySliceRelativePositionFilter.h | 5 +++++ itk/clitkSliceBySliceRelativePositionFilter.txx | 12 ++++++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/itk/clitkSegmentationUtils.h b/itk/clitkSegmentationUtils.h index 6fa67aa..322f1ee 100644 --- a/itk/clitkSegmentationUtils.h +++ b/itk/clitkSegmentationUtils.h @@ -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 diff --git a/itk/clitkSegmentationUtils.txx b/itk/clitkSegmentationUtils.txx index 42ddc47..3da1802 100644 --- a/itk/clitkSegmentationUtils.txx +++ b/itk/clitkSegmentationUtils.txx @@ -297,7 +297,8 @@ namespace clitk { { typename ImageType::Pointer working_image; working_image = Labelize(input, BG, isFullyConnected, minimalComponentSize); - working_image = RemoveLabels(working_image, BG, param->GetLabelsToRemove()); + if (param->GetLabelsToRemove().size() != 0) + working_image = RemoveLabels(working_image, BG, param->GetLabelsToRemove()); working_image = KeepLabels(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 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(); } diff --git a/itk/clitkSliceBySliceRelativePositionFilter.h b/itk/clitkSliceBySliceRelativePositionFilter.h index 0da64dc..be31dfc 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.h +++ b/itk/clitkSliceBySliceRelativePositionFilter.h @@ -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 diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index eafb416..6a4b0f4 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -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(mObjectSlices[i], 0, true, 1, nb); if ((!GetIgnoreEmptySliceObjectFlag()) || (nb!=0)) { - mObjectSlices[i] = KeepLabels(mObjectSlices[i], 0, 1, 1, 1, true); + + // Select or not a single CCL ? + if (GetUseASingleObjectConnectedComponentBySliceFlag()) { + mObjectSlices[i] = KeepLabels(mObjectSlices[i], 0, 1, 1, 1, true); + } // Relative position typedef clitk::AddRelativePositionConstraintToLabelImageFilter RelPosFilterType; -- 2.47.1