From: dsarrut Date: Tue, 15 Feb 2011 10:44:07 +0000 (+0000) Subject: simplify, correct default X-Git-Tag: v1.2.0~257 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=cd0b3ebc56173699e23b90bc911e9caf8b7145c9;p=clitk.git simplify, correct default --- diff --git a/itk/clitkSliceBySliceRelativePositionFilter.h b/itk/clitkSliceBySliceRelativePositionFilter.h index bc8ae97..e17a759 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.h +++ b/itk/clitkSliceBySliceRelativePositionFilter.h @@ -33,13 +33,12 @@ namespace clitk { template class ITK_EXPORT SliceBySliceRelativePositionFilter: - public clitk::FilterBase, - public itk::ImageToImageFilter + public AddRelativePositionConstraintToLabelImageFilter { public: /** Standard class typedefs. */ - typedef itk::ImageToImageFilter Superclass; + typedef AddRelativePositionConstraintToLabelImageFilter Superclass; typedef SliceBySliceRelativePositionFilter Self; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; @@ -69,49 +68,57 @@ namespace clitk { /** Input : initial image and object */ void SetInput(const ImageType * image); void SetInputObject(const ImageType * image); - + // Options + void PrintOptions(); itkGetConstMacro(Direction, int); itkSetMacro(Direction, int); - itkGetConstMacro(ObjectBackgroundValue, PixelType); - itkSetMacro(ObjectBackgroundValue, PixelType); + // itkGetConstMacro(ObjectBackgroundValue, PixelType); + // itkSetMacro(ObjectBackgroundValue, PixelType); - itkSetMacro(OrientationTypeString, std::string); - itkGetConstMacro(OrientationTypeString, std::string); + // itkSetMacro(OrientationTypeString, std::string); + // itkGetConstMacro(OrientationTypeString, std::string); - itkGetConstMacro(ResampleBeforeRelativePositionFilter, bool); - itkSetMacro(ResampleBeforeRelativePositionFilter, bool); - itkBooleanMacro(ResampleBeforeRelativePositionFilter); + // itkGetConstMacro(ResampleBeforeRelativePositionFilter, bool); + // itkSetMacro(ResampleBeforeRelativePositionFilter, bool); + // itkBooleanMacro(ResampleBeforeRelativePositionFilter); - itkGetConstMacro(IntermediateSpacing, double); - itkSetMacro(IntermediateSpacing, double); + // itkGetConstMacro(IntermediateSpacing, double); + // itkSetMacro(IntermediateSpacing, double); - itkGetConstMacro(FuzzyThreshold, double); - itkSetMacro(FuzzyThreshold, double); + // itkGetConstMacro(FuzzyThreshold, double); + // itkSetMacro(FuzzyThreshold, double); itkGetConstMacro(UniqueConnectedComponentBySlice, bool); itkSetMacro(UniqueConnectedComponentBySlice, bool); itkBooleanMacro(UniqueConnectedComponentBySlice); - itkGetConstMacro(AutoCropFlag, bool); - itkSetMacro(AutoCropFlag, bool); - itkBooleanMacro(AutoCropFlag); + // 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(NotFlag, bool); - itkSetMacro(NotFlag, bool); - itkBooleanMacro(NotFlag); + // itkGetConstMacro(CombineWithOrFlag, bool); + // itkSetMacro(CombineWithOrFlag, bool); + // itkBooleanMacro(CombineWithOrFlag); protected: SliceBySliceRelativePositionFilter(); virtual ~SliceBySliceRelativePositionFilter() {} - int m_Direction; - PixelType m_ObjectBackgroundValue; + // PixelType m_ObjectBackgroundValue; // OrientationTypeEnumeration m_OrientationType; - std::string m_OrientationTypeString; - double m_IntermediateSpacing; - double m_FuzzyThreshold; - bool m_ResampleBeforeRelativePositionFilter; + // std::string m_OrientationTypeString; + // double m_IntermediateSpacing; + // double m_FuzzyThreshold; + // bool m_ResampleBeforeRelativePositionFilter; virtual void GenerateOutputInformation(); virtual void GenerateInputRequestedRegion(); @@ -121,9 +128,12 @@ namespace clitk { ImagePointer object; ImagePointer m_working_input; ImagePointer m_working_object; - bool m_UniqueConnectedComponentBySlice; - bool m_NotFlag; - bool m_AutoCropFlag; + bool m_UniqueConnectedComponentBySlice; + int m_Direction; + // bool m_InverseOrientationFlag; + // bool m_RemoveObjectFlag; + // bool m_AutoCropFlag; + // bool m_CombineWithOrFlag; private: SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index bdffecb..36564cc 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -28,18 +28,10 @@ template clitk::SliceBySliceRelativePositionFilter:: SliceBySliceRelativePositionFilter(): - clitk::FilterBase(), - itk::ImageToImageFilter() + clitk::AddRelativePositionConstraintToLabelImageFilter() { - this->SetNumberOfRequiredInputs(2); SetDirection(2); - SetObjectBackgroundValue(0); - SetFuzzyThreshold(0.6); - SetOrientationTypeString("Left"); - SetIntermediateSpacing(10); - ResampleBeforeRelativePositionFilterOff(); UniqueConnectedComponentBySliceOff(); - NotFlagOff(); } //-------------------------------------------------------------------- @@ -68,6 +60,27 @@ SetInputObject(const ImageType * image) //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +void +clitk::SliceBySliceRelativePositionFilter:: +PrintOptions() +{ + DD(this->GetDirection()); + DD((int)this->GetObjectBackgroundValue()); + DDV(this->GetOrientationTypeString(), (uint)this->GetNumberOfAngles()); + DD(this->GetResampleBeforeRelativePositionFilter()); + DD(this->GetIntermediateSpacing()); + DD(this->GetFuzzyThreshold()); + DD(this->GetUniqueConnectedComponentBySlice()); + DD(this->GetAutoCropFlag()); + DD(this->GetInverseOrientationFlag()); + DD(this->GetRemoveObjectFlag()); + DD(this->GetCombineWithOrFlag()); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- template void @@ -91,6 +104,10 @@ void clitk::SliceBySliceRelativePositionFilter:: GenerateOutputInformation() { + if (this->GetVerboseOptionFlag()) { + PrintOptions(); + } + // Get input pointer input = dynamic_cast(itk::ProcessObject::GetInput(0)); object = dynamic_cast(itk::ProcessObject::GetInput(1)); @@ -98,9 +115,9 @@ GenerateOutputInformation() //-------------------------------------------------------------------- // Resample object to the same spacing than input if (!clitk::HaveSameSpacing(object, input)) { - StartNewStep("Resample object to the same spacing than input"); + this->StartNewStep("Resample object to the same spacing than input"); m_working_object = clitk::ResampleImageSpacing(object, input->GetSpacing()); - StopCurrentStep(m_working_object); + this->template StopCurrentStep(m_working_object); } else { m_working_object = object; @@ -109,11 +126,11 @@ GenerateOutputInformation() //-------------------------------------------------------------------- // Pad object to the same size than input if (!clitk::HaveSameSizeAndSpacing(m_working_object, input)) { - StartNewStep("Pad object to the same size than input"); + this->StartNewStep("Pad object to the same size than input"); m_working_object = clitk::ResizeImageLike(m_working_object, input, - GetObjectBackgroundValue()); - StopCurrentStep(m_working_object); + this->GetObjectBackgroundValue()); + this->template StopCurrentStep(m_working_object); } else { } @@ -128,7 +145,7 @@ GenerateOutputInformation() //-------------------------------------------------------------------- // Extract input slices - StartNewStep("Extract input slices"); + this->StartNewStep("Extract input slices"); typedef clitk::ExtractSliceFilter ExtractSliceFilterType; typename ExtractSliceFilterType::Pointer extractSliceFilter = ExtractSliceFilterType::New(); extractSliceFilter->SetInput(input); @@ -137,22 +154,22 @@ GenerateOutputInformation() typedef typename ExtractSliceFilterType::SliceType SliceType; std::vector mInputSlices; extractSliceFilter->GetOutputSlices(mInputSlices); - StopCurrentStep(mInputSlices[0]); + this->template StopCurrentStep(mInputSlices[0]); //-------------------------------------------------------------------- // Extract object slices - StartNewStep("Extract object slices"); + this->StartNewStep("Extract object slices"); extractSliceFilter = ExtractSliceFilterType::New(); extractSliceFilter->SetInput(m_working_object);//object); extractSliceFilter->SetDirection(GetDirection()); extractSliceFilter->Update(); std::vector mObjectSlices; extractSliceFilter->GetOutputSlices(mObjectSlices); - StopCurrentStep(mObjectSlices[0]); + this->template StopCurrentStep(mObjectSlices[0]); //-------------------------------------------------------------------- // Perform slice by slice relative position - StartNewStep("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); @@ -161,17 +178,23 @@ GenerateOutputInformation() // Relative position typedef clitk::AddRelativePositionConstraintToLabelImageFilter RelPosFilterType; typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New(); - relPosFilter->VerboseStepOff(); - relPosFilter->WriteStepOff(); + relPosFilter->VerboseStepFlagOff(); + relPosFilter->WriteStepFlagOff(); relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId()); + relPosFilter->SetBackgroundValue(this->GetBackgroundValue()); relPosFilter->SetInput(mInputSlices[i]); relPosFilter->SetInputObject(mObjectSlices[i]); - relPosFilter->SetNotFlag(GetNotFlag()); - relPosFilter->SetOrientationTypeString(this->GetOrientationTypeString()); + 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(); @@ -183,28 +206,21 @@ GenerateOutputInformation() } - typedef itk::JoinSeriesImageFilter JoinSeriesFilterType; - typename JoinSeriesFilterType::Pointer joinFilter = JoinSeriesFilterType::New(); - joinFilter->SetOrigin(input->GetOrigin()[GetDirection()]); - joinFilter->SetSpacing(input->GetSpacing()[GetDirection()]); - for(unsigned int i=0; iPushBackInput(mInputSlices[i]); - } - joinFilter->Update(); - m_working_input = joinFilter->GetOutput(); - StopCurrentStep(m_working_input); + // Join the slices + m_working_input = clitk::JoinSlices(mInputSlices, input, GetDirection()); + this->template StopCurrentStep(m_working_input); //-------------------------------------------------------------------- // Step 7: autocrop - if (GetAutoCropFlag()) { - StartNewStep("Final AutoCrop"); + if (this->GetAutoCropFlag()) { + this->StartNewStep("Final AutoCrop"); typedef clitk::AutoCropFilter CropFilterType; typename CropFilterType::Pointer cropFilter = CropFilterType::New(); cropFilter->SetInput(m_working_input); cropFilter->ReleaseDataFlagOff(); cropFilter->Update(); m_working_input = cropFilter->GetOutput(); - StopCurrentStep(m_working_input); + this->template StopCurrentStep(m_working_input); } // Update output info