From 369c7dae5e7f834096e7c9cee50f27112b420705 Mon Sep 17 00:00:00 2001 From: Vivien Delmon Date: Tue, 14 Jun 2011 09:38:15 +0200 Subject: [PATCH] Add test outside SearchForTrackea to avoid infinite loop When clitkExtractLung did not find the trackea it looped infinitly. --- segmentation/clitkExtractLungFilter.txx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/segmentation/clitkExtractLungFilter.txx b/segmentation/clitkExtractLungFilter.txx index 1a94591..3a098e9 100644 --- a/segmentation/clitkExtractLungFilter.txx +++ b/segmentation/clitkExtractLungFilter.txx @@ -591,7 +591,7 @@ ComputeTracheaVolume() //-------------------------------------------------------------------- template -void +void clitk::ExtractLungFilter:: SearchForTrachea() { @@ -606,8 +606,8 @@ SearchForTrachea() double volume = 0.0; int skip = GetNumberOfSlicesToSkipBeforeSearchingSeed(); while (!stop) { - stop = SearchForTracheaSeed(skip); - if (stop) { + stop = true; + if (SearchForTracheaSeed(skip)) { TracheaRegionGrowing(); volume = ComputeTracheaVolume()/1000; // assume mm3, so divide by 1000 to get cc if (GetWriteStepFlag()) { @@ -619,7 +619,6 @@ SearchForTrachea() if (GetVerboseStepFlag()) { std::cout << "\t Found trachea with volume " << volume << " cc." << std::endl; } - stop = true; } else { if (GetVerboseStepFlag()) { @@ -632,6 +631,11 @@ SearchForTrachea() // empty the list of seed m_Seeds.clear(); } + if (skip > 0.5 * working_input->GetLargestPossibleRegion().GetSize()[2]) { + // we want to skip more than a half of the image, it is probably a bug + std::cerr << "2 : Number of slices to skip to find trachea too high = " << skip << std::endl; + stop = true; + } } else { stop = true; -- 2.47.1