X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSliceBySliceRelativePositionFilter.txx;h=db3c677c0e8701c2a424676fcd72117e26576b12;hb=4d169a2b4d862ed8bb9155b358776ffe08154c76;hp=449ffff9f5a06162a5ed1b11b387a9ade104e549;hpb=4efd93f02e07c2d8fe45f29f9579cabe27a93c1a;p=clitk.git diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index 449ffff..db3c677 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -42,6 +42,7 @@ SliceBySliceRelativePositionFilter(): SetObjectCCLSelectionDimension(0); SetObjectCCLSelectionDirection(1); ObjectCCLSelectionIgnoreSingleCCLFlagOff(); + VerboseSlicesFlagOff(); } //-------------------------------------------------------------------- @@ -95,7 +96,9 @@ PrintOptions(std::ostream & os) << "ObjectCCLSelectionFlag = " << this->GetObjectCCLSelectionFlag() << std::endl << "ObjectCCLSelectionDimension = " << this->GetObjectCCLSelectionDimension() << std::endl << "ObjectCCLSelectionIgnoreSingleCCLFlag = " << this->GetObjectCCLSelectionIgnoreSingleCCLFlag() << std::endl - << "IgnoreEmptySliceObjectFlag = " << this->GetIgnoreEmptySliceObjectFlag() << std::endl; + << "IgnoreEmptySliceObjectFlag = " << this->GetIgnoreEmptySliceObjectFlag() << std::endl + << "(RP) FastFlag = " << this->GetFastFlag() << std::endl + << "(RP) Radius = " << this->GetRadius() << std::endl; } //-------------------------------------------------------------------- @@ -127,7 +130,7 @@ GenerateOutputInformation() PrintOptions(); } - if (this->GetFuzzyMapOnlyFlag()) this->ComputeFuzzyMapFlagOn(); + // if (this->GetFuzzyMapOnlyFlag()) this->ComputeFuzzyMapFlagOn(); // Get input pointer input = dynamic_cast(itk::ProcessObject::GetInput(0)); @@ -179,6 +182,13 @@ GenerateOutputInformation() m_working_object = clitk::ResizeImageLike(m_working_object, m_working_input, this->GetObjectBackgroundValue()); + + // Index can be negative in some cases, and lead to problem with + // some filter. So we correct it. + m_working_input = clitk::RemoveNegativeIndexFromRegion(m_working_input); + m_working_object = clitk::RemoveNegativeIndexFromRegion(m_working_object); + + // End this->template StopCurrentStep(m_working_input); } @@ -221,7 +231,7 @@ GenerateOutputInformation() //-------------------------------------------------------------------- // Perform slice by slice relative position - this->StartNewStep("Perform slice by slice relative position"); + this->StartNewStep("Perform slice by slice relative position ("+toString(mInputSlices.size())+")"); for(unsigned int i=0; i(mObjectSlices[i], 0, true, 1, nb); // If no object and empty slices and if we need the full fuzzy map, create a dummy one. - if ((nb==0) && (this->GetComputeFuzzyMapFlag())) { + if ((nb==0) && (this->GetFuzzyMapOnlyFlag())) { typename FloatSliceType::Pointer one = FloatSliceType::New(); one->CopyInformation(mObjectSlices[0]); one->SetRegions(mObjectSlices[0]->GetLargestPossibleRegion()); @@ -281,17 +291,18 @@ GenerateOutputInformation() // Relative position typedef clitk::AddRelativePositionConstraintToLabelImageFilter RelPosFilterType; typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New(); - relPosFilter->VerboseStepFlagOff(); + if (GetVerboseSlicesFlag()) { + std::cout << "Slice " << i << std::endl; + relPosFilter->VerboseStepFlagOn(); + } relPosFilter->WriteStepFlagOff(); // relPosFilter->VerboseMemoryFlagOn(); - relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId()+"-"+toString(i)); - + relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId()+"-"+toString(i)); relPosFilter->SetBackgroundValue(this->GetBackgroundValue()); relPosFilter->SetInput(mInputSlices[i]); relPosFilter->SetInputObject(mObjectSlices[i]); - relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag()); - + relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag()); // This flag (InverseOrientation) *must* be set before // AddOrientation because AddOrientation can change it. relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag()); @@ -303,16 +314,17 @@ GenerateOutputInformation() relPosFilter->SetFuzzyThreshold(this->GetFuzzyThreshold()); relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop relPosFilter->SetCombineWithOrFlag(this->GetCombineWithOrFlag()); - // should we stop after fuzzy map ? relPosFilter->SetFuzzyMapOnlyFlag(this->GetFuzzyMapOnlyFlag()); - relPosFilter->SetComputeFuzzyMapFlag(this->GetComputeFuzzyMapFlag()); - + // relPosFilter->SetComputeFuzzyMapFlag(this->GetComputeFuzzyMapFlag()); + relPosFilter->SetFastFlag(this->GetFastFlag()); + relPosFilter->SetRadius(this->GetRadius()); + // Go ! relPosFilter->Update(); // If we stop after the fuzzy map, store the fuzzy slices - if (this->GetComputeFuzzyMapFlag()) { + if (this->GetFuzzyMapOnlyFlag()) { mFuzzyMapSlices[i] = relPosFilter->GetFuzzyMap(); // writeImage(mFuzzyMapSlices[i], "slice_"+toString(i)+".mha"); } @@ -348,7 +360,7 @@ GenerateOutputInformation() this->template StopCurrentStep(m_working_input); // Join the fuzzy map if needed - if (this->GetComputeFuzzyMapFlag()) { + if (this->GetFuzzyMapOnlyFlag()) { this->m_FuzzyMap = clitk::JoinSlices(mFuzzyMapSlices, m_working_input, GetDirection()); this->template StopCurrentStep(this->m_FuzzyMap); if (this->GetFuzzyMapOnlyFlag()) return;