X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSliceBySliceRelativePositionFilter.txx;h=16571ea7a224df6b17d87425d7cf8bde619a66b0;hb=3a823a03d4a2217e41e4dd3b05a8ea825bb762a5;hp=449ffff9f5a06162a5ed1b11b387a9ade104e549;hpb=9a4dda175415c133b547eec505cd0497d3181f8d;p=clitk.git diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index 449ffff..16571ea 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -42,6 +42,8 @@ SliceBySliceRelativePositionFilter(): SetObjectCCLSelectionDimension(0); SetObjectCCLSelectionDirection(1); ObjectCCLSelectionIgnoreSingleCCLFlagOff(); + VerboseSlicesFlagOff(); + this->SetK1(vcl_acos(-1.0)/2); } //-------------------------------------------------------------------- @@ -77,7 +79,7 @@ clitk::SliceBySliceRelativePositionFilter:: PrintOptions(std::ostream & os) { os << "Slice direction = " << this->GetDirection() << std::endl - << "BG value = " << this->GetBackgroundValue() << std::endl; + << "BG value = " << (int)this->GetBackgroundValue() << std::endl; for(int i=0; iGetNumberOfAngles(); i++) { os << "Orientation = " << this->GetOrientationTypeString()[i] << std::endl; os << "Angles = " << clitk::rad2deg(this->GetAngle1InRad(i)) @@ -95,7 +97,10 @@ 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 + << "(RP) K1 = " << this->GetK1() << std::endl; } //-------------------------------------------------------------------- @@ -127,7 +132,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 +184,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,15 +233,19 @@ 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 (GetVerboseSlicesFlag()) { + std::cout << "slice " << i << " nb = " << nb << std::endl; + } + // 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 +297,19 @@ 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->WriteStepFlagOn(); + } 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 +321,18 @@ 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()); + relPosFilter->SetK1(this->GetK1()); + // 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 +368,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;