X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkExtractLungFilter.txx;h=d2bff5edd5962647512fd2d1070017b17a5dab34;hb=e2b37672d5ee8eafc7b1ac075f4e70596349f0c3;hp=0954c2a3de46a11249c21237b9644e9a4a123404;hpb=6194949c0beb1589904e22381b9aba1bbface172;p=clitk.git diff --git a/segmentation/clitkExtractLungFilter.txx b/segmentation/clitkExtractLungFilter.txx index 0954c2a..d2bff5e 100644 --- a/segmentation/clitkExtractLungFilter.txx +++ b/segmentation/clitkExtractLungFilter.txx @@ -414,49 +414,51 @@ GenerateOutputInformation() StopCurrentStep(working_mask); } - //-------------------------------------------------------------------- - //-------------------------------------------------------------------- - StartNewStep("Separate Left/Right lungs"); - PrintMemory(GetVerboseMemoryFlag(), "Before Separate"); - // Initial label - working_mask = Labelize(working_mask, - GetBackgroundValue(), - false, - GetMinimalComponentSize()); - - PrintMemory(GetVerboseMemoryFlag(), "After Labelize"); - - // Count the labels - typedef itk::StatisticsImageFilter StatisticsImageFilterType; - typename StatisticsImageFilterType::Pointer statisticsImageFilter=StatisticsImageFilterType::New(); - statisticsImageFilter->SetInput(working_mask); - statisticsImageFilter->Update(); - unsigned int initialNumberOfLabels = statisticsImageFilter->GetMaximum(); - working_mask = statisticsImageFilter->GetOutput(); + if (GetSeparateLungsFlag()) { + //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + StartNewStep("Separate Left/Right lungs"); + PrintMemory(GetVerboseMemoryFlag(), "Before Separate"); + // Initial label + working_mask = Labelize(working_mask, + GetBackgroundValue(), + false, + GetMinimalComponentSize()); + + PrintMemory(GetVerboseMemoryFlag(), "After Labelize"); + + // Count the labels + typedef itk::StatisticsImageFilter StatisticsImageFilterType; + typename StatisticsImageFilterType::Pointer statisticsImageFilter=StatisticsImageFilterType::New(); + statisticsImageFilter->SetInput(working_mask); + statisticsImageFilter->Update(); + unsigned int initialNumberOfLabels = statisticsImageFilter->GetMaximum(); + working_mask = statisticsImageFilter->GetOutput(); + + PrintMemory(GetVerboseMemoryFlag(), "After count label"); - PrintMemory(GetVerboseMemoryFlag(), "After count label"); - - // Decompose the first label - if (initialNumberOfLabels<2) { - // Structuring element radius - typename ImageType::SizeType radius; - for (unsigned int i=0;i DecomposeAndReconstructFilterType; - typename DecomposeAndReconstructFilterType::Pointer decomposeAndReconstructFilter=DecomposeAndReconstructFilterType::New(); - decomposeAndReconstructFilter->SetInput(working_mask); - decomposeAndReconstructFilter->SetVerbose(false); - decomposeAndReconstructFilter->SetRadius(radius); - decomposeAndReconstructFilter->SetMaximumNumberOfLabels(2); - decomposeAndReconstructFilter->SetMinimumObjectSize(this->GetMinimalComponentSize()); - decomposeAndReconstructFilter->SetMinimumNumberOfIterations(1); - decomposeAndReconstructFilter->SetBackgroundValue(this->GetBackgroundValue()); - decomposeAndReconstructFilter->SetForegroundValue(this->GetForegroundValue()); - decomposeAndReconstructFilter->SetFullyConnected(true); - decomposeAndReconstructFilter->SetNumberOfNewLabels(1); - decomposeAndReconstructFilter->Update(); - working_mask = decomposeAndReconstructFilter->GetOutput(); + // Decompose the first label + if (initialNumberOfLabels<2) { + // Structuring element radius + typename ImageType::SizeType radius; + for (unsigned int i=0;i DecomposeAndReconstructFilterType; + typename DecomposeAndReconstructFilterType::Pointer decomposeAndReconstructFilter=DecomposeAndReconstructFilterType::New(); + decomposeAndReconstructFilter->SetInput(working_mask); + decomposeAndReconstructFilter->SetVerbose(false); + decomposeAndReconstructFilter->SetRadius(radius); + decomposeAndReconstructFilter->SetMaximumNumberOfLabels(2); + decomposeAndReconstructFilter->SetMinimumObjectSize(this->GetMinimalComponentSize()); + decomposeAndReconstructFilter->SetMinimumNumberOfIterations(1); + decomposeAndReconstructFilter->SetBackgroundValue(this->GetBackgroundValue()); + decomposeAndReconstructFilter->SetForegroundValue(this->GetForegroundValue()); + decomposeAndReconstructFilter->SetFullyConnected(true); + decomposeAndReconstructFilter->SetNumberOfNewLabels(1); + decomposeAndReconstructFilter->Update(); + working_mask = decomposeAndReconstructFilter->GetOutput(); + } + PrintMemory(GetVerboseMemoryFlag(), "After decomposeAndReconstructFilter"); } - PrintMemory(GetVerboseMemoryFlag(), "After decomposeAndReconstructFilter"); // Retain labels ('1' is largset lung, so right. '2' is left) typedef itk::ThresholdImageFilter ThresholdImageFilterType;