From: dsarrut Date: Tue, 22 Feb 2011 07:12:45 +0000 (+0000) Subject: cosmetic X-Git-Tag: v1.2.0~233 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=72375037f90c596a034b2ebe5e54e209e7b45511;p=clitk.git cosmetic --- diff --git a/itk/clitkSliceBySliceRelativePositionFilter.h b/itk/clitkSliceBySliceRelativePositionFilter.h index e17a759..4a3ebda 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.h +++ b/itk/clitkSliceBySliceRelativePositionFilter.h @@ -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 diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index 36564cc..e380102 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -32,6 +32,7 @@ SliceBySliceRelativePositionFilter(): { SetDirection(2); UniqueConnectedComponentBySliceOff(); + SetIgnoreEmptySliceObject(false); } //-------------------------------------------------------------------- @@ -128,8 +129,8 @@ GenerateOutputInformation() if (!clitk::HaveSameSizeAndSpacing(m_working_object, input)) { this->StartNewStep("Pad object to the same size than input"); m_working_object = clitk::ResizeImageLike(m_working_object, - input, - this->GetObjectBackgroundValue()); + input, + this->GetObjectBackgroundValue()); this->template StopCurrentStep(m_working_object); } else { @@ -172,38 +173,41 @@ GenerateOutputInformation() this->StartNewStep("Perform slice by slice relative position"); for(unsigned int i=0; i(mObjectSlices[i], 0, true, 1); - mObjectSlices[i] = KeepLabels(mObjectSlices[i], 0, 1, 1, 1, true); - - // Relative position - typedef clitk::AddRelativePositionConstraintToLabelImageFilter 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; jGetNumberOfAngles(); 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(mInputSlices[i], 0, true, 1); - mInputSlices[i] = KeepLabels(mInputSlices[i], 0, 1, 1, 1, true); - } + int nb=0; + mObjectSlices[i] = LabelizeAndCountNumberOfObjects(mObjectSlices[i], 0, true, 1, nb); + if ((!GetIgnoreEmptySliceObject()) || (nb!=0)) { + mObjectSlices[i] = KeepLabels(mObjectSlices[i], 0, 1, 1, 1, true); + + // Relative position + typedef clitk::AddRelativePositionConstraintToLabelImageFilter 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; jGetNumberOfAngles(); 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(mInputSlices[i], 0, true, 1); + mInputSlices[i] = KeepLabels(mInputSlices[i], 0, 1, 1, 1, true); + } + } } // Join the slices