X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkAddRelativePositionConstraintToLabelImageFilter.txx;h=6d536186fbf5084da969d0750e05a4cc8cd3c8fb;hb=941d5dc33f764cc2f1a4091be1746de8c0b25ec2;hp=1ea25f07837fb30ac31cb8224ac396ac64efa214;hpb=b2b8c52b0db448b1ca2286b07c548be05466da0e;p=clitk.git diff --git a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx index 1ea25f0..6d53618 100644 --- a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx +++ b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx @@ -63,6 +63,8 @@ AddRelativePositionConstraintToLabelImageFilter(): VerboseStepFlagOff(); WriteStepFlagOff(); FuzzyMapOnlyFlagOff(); + FastFlagOff(); + SetRadius(2.0); } //-------------------------------------------------------------------- @@ -179,7 +181,7 @@ GenerateInputRequestedRegion() template void clitk::AddRelativePositionConstraintToLabelImageFilter:: -AddAngles(double a, double b) +AddAnglesInRad(double a, double b) { m_OrientationTypeString.push_back("Angle"); m_OrientationType.push_back(Angle); @@ -189,6 +191,17 @@ AddAngles(double a, double b) //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +void +clitk::AddRelativePositionConstraintToLabelImageFilter:: +AddAnglesInDeg(double a, double b) +{ + AddAnglesInRad(clitk::deg2rad(a), clitk::deg2rad(b)); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- template void @@ -369,12 +382,16 @@ GenerateData() for(int i=0; iSetFast(GetFastFlag()); + relPosFilter->SetRadius(GetRadius()); relPosFilter->SetInput(working_image); relPosFilter->SetAlpha1(m_Angle1[i]); // xy plane relPosFilter->SetAlpha2(m_Angle2[i]); relPosFilter->SetK1(M_PI/2.0); // Opening parameter, default = pi/2 - relPosFilter->SetFast(true); - relPosFilter->SetRadius(1); // seems sufficient in this case + + // relPosFilter->SetFast(true); + // relPosFilter->SetRadius(1); // seems sufficient in this case + // relPosFilter->SetVerboseProgress(true); relPosFilter->Update(); relPos = relPosFilter->GetOutput(); @@ -415,7 +432,43 @@ GenerateData() relPos = m_FuzzyMap; StopCurrentStep(relPos); - if (GetFuzzyMapOnlyFlag()) return; + if (GetFuzzyMapOnlyFlag()) { + // If the spacing is used, recompute fuzzy map with the input size/spacing + if (m_IntermediateSpacingFlag) { + StartNewStep("Resample FuzzyMap to come back to the same sampling than input"); + typedef clitk::ResampleImageWithOptionsFilter ResampleFilterType; + typename ResampleFilterType::Pointer resampleFilter = ResampleFilterType::New(); + resampleFilter->SetDefaultPixelValue(0.0); //Default fuzzymap value FIXME + resampleFilter->SetInput(relPos); + resampleFilter->SetOutputSpacing(input->GetSpacing()); + resampleFilter->SetGaussianFilteringEnabled(false); + resampleFilter->Update(); + relPos = m_FuzzyMap = resampleFilter->GetOutput(); + + // Need to put exactly the same size + if (relPos->GetLargestPossibleRegion() != input->GetLargestPossibleRegion()) { + StartNewStep("Pad to get the same size than input"); + typename FloatImageType::Pointer temp = FloatImageType::New(); + temp->CopyInformation(input); + temp->SetRegions(input->GetLargestPossibleRegion()); // Do not forget !! + temp->Allocate(); + temp->FillBuffer(0.0); // Default fuzzymap value FIXME + typename PasteFloatFilterType::Pointer padFilter2 = PasteFloatFilterType::New(); + padFilter2->SetSourceImage(relPos); + padFilter2->SetDestinationImage(temp); + padFilter2->SetDestinationIndex(input->GetLargestPossibleRegion().GetIndex()); + padFilter2->SetSourceRegion(relPos->GetLargestPossibleRegion()); + padFilter2->Update(); + relPos = padFilter2->GetOutput(); + StopCurrentStep(relPos); + m_FuzzyMap = relPos; + } + } + else { + StopCurrentStep(relPos); + } + return; + } //-------------------------------------------------------------------- //--------------------------------------------------------------------