X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSliceBySliceRelativePositionFilter.txx;h=0548146d2051ffe0b61289dc2d07fbf52d6af95b;hb=4f4d79533d2bdd0c13d90cde6bbb67e5f313b638;hp=76b0fec9cb35281aa8b8860a1f30313c1902013a;hpb=a360b70353c02d20482d950c96ba7b289deca184;p=clitk.git diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index 76b0fec..0548146 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -31,16 +31,16 @@ SliceBySliceRelativePositionFilter(): clitk::AddRelativePositionConstraintToLabelImageFilter() { SetDirection(2); - UniqueConnectedComponentBySliceOff(); + UniqueConnectedComponentBySliceFlagOff(); SetIgnoreEmptySliceObjectFlag(false); - UseASingleObjectConnectedComponentBySliceFlagOn(); + UseTheLargestObjectCCLFlagOff(); this->VerboseStepFlagOff(); this->WriteStepFlagOff(); this->SetCombineWithOrFlag(false); - CCLSelectionFlagOn(); - SetCCLSelectionDimension(0); - SetCCLSelectionDirection(1); - CCLSelectionIgnoreSingleCCLFlagOff(); + ObjectCCLSelectionFlagOff(); + SetObjectCCLSelectionDimension(0); + SetObjectCCLSelectionDirection(1); + ObjectCCLSelectionIgnoreSingleCCLFlagOff(); } //-------------------------------------------------------------------- @@ -73,19 +73,25 @@ SetInputObject(const ImageType * image) template void clitk::SliceBySliceRelativePositionFilter:: -PrintOptions() +PrintOptions(std::ostream & os) { - DD(this->GetDirection()); - DD((int)this->GetObjectBackgroundValue()); - DDV(this->GetOrientationTypeString(), (uint)this->GetNumberOfAngles()); - DD(this->GetIntermediateSpacingFlag()); - DD(this->GetIntermediateSpacing()); - DD(this->GetFuzzyThreshold()); - DD(this->GetUniqueConnectedComponentBySlice()); - DD(this->GetAutoCropFlag()); - DD(this->GetInverseOrientationFlag()); - DD(this->GetRemoveObjectFlag()); - DD(this->GetCombineWithOrFlag()); + os << "Slice direction = " << this->GetDirection() << std::endl + << "BG value = " << this->GetBackgroundValue() << std::endl; + for(int i=0; iGetNumberOfAngles(); i++) + os << "Orientation = " << this->GetOrientationTypeString()[i] << std::endl; + os << "InverseOrientationFlag = " << this->GetInverseOrientationFlag() << std::endl + << "SpacingFlag = " << this->GetIntermediateSpacingFlag() << std::endl + << "Spacing = " << this->GetIntermediateSpacing() << std::endl + << "FuzzyThreshold = " << this->GetFuzzyThreshold() << std::endl + << "UniqueConnectedComponentBySliceFlag = " << this->GetUniqueConnectedComponentBySliceFlag() << std::endl + << "AutoCropFlag = " << this->GetAutoCropFlag() << std::endl + << "RemoveObjectFlag= " << this->GetRemoveObjectFlag() << std::endl + << "CombineWithOrFlag = " << this->GetCombineWithOrFlag() << std::endl + << "UseTheLargestObjectCCLFlag = " << this->GetUseTheLargestObjectCCLFlag() << std::endl + << "ObjectCCLSelectionFlag = " << this->GetObjectCCLSelectionFlag() << std::endl + << "ObjectCCLSelectionDimension = " << this->GetObjectCCLSelectionDimension() << std::endl + << "ObjectCCLSelectionIgnoreSingleCCLFlag = " << this->GetObjectCCLSelectionIgnoreSingleCCLFlag() << std::endl + << "IgnoreEmptySliceObjectFlag = " << this->GetIgnoreEmptySliceObjectFlag() << std::endl; } //-------------------------------------------------------------------- @@ -187,23 +193,23 @@ GenerateOutputInformation() if ((!GetIgnoreEmptySliceObjectFlag()) || (nb!=0)) { // Select or not a single CCL ? - if (GetUseASingleObjectConnectedComponentBySliceFlag()) { + if (GetUseTheLargestObjectCCLFlag()) { mObjectSlices[i] = KeepLabels(mObjectSlices[i], 0, 1, 1, 1, true); } // Select a single according to a position if more than one CCL - if (GetCCLSelectionFlag()) { + if (GetObjectCCLSelectionFlag()) { // if several CCL, choose the most extrema according a direction, // if not -> should we consider this slice ? if (nb<2) { - if (GetCCLSelectionIgnoreSingleCCLFlag()) { + if (GetObjectCCLSelectionIgnoreSingleCCLFlag()) { mObjectSlices[i] = SetBackground(mObjectSlices[i], mObjectSlices[i], 1, this->GetBackgroundValue(), true); } } - int dim = GetCCLSelectionDimension(); - int direction = GetCCLSelectionDirection(); + int dim = GetObjectCCLSelectionDimension(); + int direction = GetObjectCCLSelectionDirection(); std::vector centroids; ComputeCentroids(mObjectSlices[i], this->GetBackgroundValue(), centroids); uint index=1; @@ -222,7 +228,7 @@ GenerateOutputInformation() true); } } - } + } // end GetbjectCCLSelectionFlag = true // Relative position typedef clitk::AddRelativePositionConstraintToLabelImageFilter RelPosFilterType; @@ -234,10 +240,14 @@ GenerateOutputInformation() relPosFilter->SetInput(mInputSlices[i]); relPosFilter->SetInputObject(mObjectSlices[i]); relPosFilter->SetRemoveObjectFlag(this->GetRemoveObjectFlag()); + // This flag (InverseOrientation) *must* be set before + // AddOrientation because AddOrientation can change it. + relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag()); for(int j=0; jGetNumberOfAngles(); j++) { relPosFilter->AddOrientationTypeString(this->GetOrientationTypeString(j)); + //DD(this->GetOrientationTypeString(j)); } - relPosFilter->SetInverseOrientationFlag(this->GetInverseOrientationFlag()); + //DD(this->GetInverseOrientationFlag()); //relPosFilter->SetOrientationType(this->GetOrientationType()); relPosFilter->SetIntermediateSpacing(this->GetIntermediateSpacing()); relPosFilter->SetIntermediateSpacingFlag(this->GetIntermediateSpacingFlag()); @@ -248,7 +258,7 @@ GenerateOutputInformation() mInputSlices[i] = relPosFilter->GetOutput(); // Select main CC if needed - if (GetUniqueConnectedComponentBySlice()) { + if (GetUniqueConnectedComponentBySliceFlag()) { mInputSlices[i] = Labelize(mInputSlices[i], 0, true, 1); mInputSlices[i] = KeepLabels(mInputSlices[i], 0, 1, 1, 1, true); }