X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSliceBySliceRelativePositionFilter.txx;h=76b0fec9cb35281aa8b8860a1f30313c1902013a;hb=f4836557301d6fafe12dd9f767f911796992f855;hp=6a4b0f49ab507a089842ef723ab58f169f3ac61f;hpb=acce45844cc7d465d97939f42a56d81a6cf80179;p=clitk.git diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index 6a4b0f4..76b0fec 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -37,6 +37,10 @@ SliceBySliceRelativePositionFilter(): this->VerboseStepFlagOff(); this->WriteStepFlagOff(); this->SetCombineWithOrFlag(false); + CCLSelectionFlagOn(); + SetCCLSelectionDimension(0); + SetCCLSelectionDirection(1); + CCLSelectionIgnoreSingleCCLFlagOff(); } //-------------------------------------------------------------------- @@ -187,6 +191,39 @@ GenerateOutputInformation() 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 several CCL, choose the most extrema according a direction, + // if not -> should we consider this slice ? + if (nb<2) { + if (GetCCLSelectionIgnoreSingleCCLFlag()) { + mObjectSlices[i] = SetBackground(mObjectSlices[i], mObjectSlices[i], + 1, this->GetBackgroundValue(), + true); + } + } + int dim = GetCCLSelectionDimension(); + int direction = GetCCLSelectionDirection(); + std::vector centroids; + ComputeCentroids(mObjectSlices[i], this->GetBackgroundValue(), centroids); + uint index=1; + for(uint j=1; j centroids[index][dim]) index = j; + } + else { + if (centroids[j][dim] < centroids[index][dim]) index = j; + } + } + for(uint v=1; v(mObjectSlices[i], mObjectSlices[i], + (char)v, this->GetBackgroundValue(), + true); + } + } + } + // Relative position typedef clitk::AddRelativePositionConstraintToLabelImageFilter RelPosFilterType; typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New(); @@ -216,6 +253,15 @@ GenerateOutputInformation() mInputSlices[i] = KeepLabels(mInputSlices[i], 0, 1, 1, 1, true); } + /* + // Select unique CC according to the most in a given direction + if (GetUniqueConnectedComponentBySliceAccordingToADirection()) { + int nb; + mInputSlices[i] = LabelizeAndCountNumberOfObjects(mInputSlices[i], 0, true, 1, nb); + std::vector & centroids; + ComputeCentroids + } + */ } }