X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkExtractPatientFilter.txx;h=97f79c5e9050bdcf1b5b4d2275ad0a32e73c60f8;hb=48727138e88f056b67312603560e600362346462;hp=43e8a9b27bc79ba6b74247fc6a857ed7d2ed08ae;hpb=03d14f479ef76137ffc1936137462d9739fb28e5;p=clitk.git diff --git a/segmentation/clitkExtractPatientFilter.txx b/segmentation/clitkExtractPatientFilter.txx index 43e8a9b..97f79c5 100644 --- a/segmentation/clitkExtractPatientFilter.txx +++ b/segmentation/clitkExtractPatientFilter.txx @@ -117,6 +117,7 @@ GenerateOutputInformation() { StartNewStep("Find low densities areas"); // Pad images with air to prevent patient touching the image border + // But the lungs can touch the outside air. In such case, use primaryOpeningRadius with 1 kernel typedef itk::ConstantPadImageFilter PadFilterType; typename PadFilterType::Pointer padFilter = PadFilterType::New(); padFilter->SetInput(input); @@ -127,7 +128,8 @@ GenerateOutputInformation() { bounds[Dim - 1] = 0; padFilter->SetPadLowerBound(bounds); padFilter->SetPadUpperBound(bounds); - + padFilter->Update(); + typedef itk::BinaryThresholdImageFilter BinarizeFilterType; typename BinarizeFilterType::Pointer binarizeFilter=BinarizeFilterType::New(); binarizeFilter->SetInput(padFilter->GetOutput()); @@ -135,6 +137,7 @@ GenerateOutputInformation() { binarizeFilter->SetUpperThreshold(GetUpperThreshold()); binarizeFilter ->SetInsideValue(this->GetForegroundValue()); binarizeFilter ->SetOutsideValue(this->GetBackgroundValue()); + padFilter->GetOutput()->ReleaseData(); working_image = binarizeFilter->GetOutput(); typedef itk::BinaryBallStructuringElement KernelType; @@ -152,6 +155,7 @@ GenerateOutputInformation() { openFilter2->SetForegroundValue(1); openFilter2->SetKernel(kernel); openFilter2->Update(); + working_image->ReleaseData(); working_image = openFilter2->GetOutput(); } @@ -163,6 +167,8 @@ GenerateOutputInformation() { connectFilter->SetBackgroundValue(this->GetBackgroundValue()); connectFilter->SetFullyConnected(false); connectFilter->Update(); + working_image->ReleaseData(); + working_image = connectFilter->GetOutput(); if (this->GetVerboseOptionFlag()) std::cout << ("RelabelComponentImageFilter") << std::endl; // Sort labels according to size @@ -171,6 +177,7 @@ GenerateOutputInformation() { relabelFilter->InPlaceOn(); relabelFilter->SetInput(connectFilter->GetOutput()); relabelFilter->Update(); + working_image->ReleaseData(); working_image = relabelFilter->GetOutput(); // End @@ -192,6 +199,7 @@ GenerateOutputInformation() { f->SetFullyConnected(true); f->SetNumberOfNewLabels(GetNumberOfNewLabels1()); f->Update(); + working_image->ReleaseData(); working_image = f->GetOutput(); StopCurrentStep(working_image); } @@ -207,16 +215,22 @@ GenerateOutputInformation() { binarizeFilter2->SetUpperThreshold(GetLastKeep()); binarizeFilter2 ->SetInsideValue(0); binarizeFilter2 ->SetOutsideValue(1); - // binarizeFilter2 ->Update(); // NEEDED ? + binarizeFilter2 ->Update(); + working_image->ReleaseData(); + working_image = binarizeFilter2->GetOutput(); typename ConnectFilterType::Pointer connectFilter2 = ConnectFilterType::New(); - connectFilter2->SetInput(binarizeFilter2->GetOutput()); + connectFilter2->SetInput(working_image); connectFilter2->SetBackgroundValue(this->GetBackgroundValue()); connectFilter2->SetFullyConnected(false); + connectFilter2->Update(); + working_image->ReleaseData(); + working_image = connectFilter2->GetOutput(); typename RelabelFilterType::Pointer relabelFilter2 = RelabelFilterType::New(); - relabelFilter2->SetInput(connectFilter2->GetOutput()); + relabelFilter2->SetInput(working_image); relabelFilter2->Update(); + working_image->ReleaseData(); working_image = relabelFilter2->GetOutput(); // Keep main label @@ -240,6 +254,7 @@ GenerateOutputInformation() { f->SetFullyConnected(true); f->SetNumberOfNewLabels(GetNumberOfNewLabels2()); f->Update(); + working_image->ReleaseData(); working_image = f->GetOutput(); StopCurrentStep(working_image); } @@ -268,6 +283,7 @@ GenerateOutputInformation() { // closeFilter->SetBackgroundValue(SetBackgroundValue()); closeFilter->SetKernel(structuringElement); closeFilter->Update(); + working_image->ReleaseData(); working_image = closeFilter->GetOutput(); StopCurrentStep(working_image); } @@ -279,6 +295,7 @@ GenerateOutputInformation() { typename CastImageFilterType::Pointer caster= CastImageFilterType::New(); caster->SetInput(working_image); caster->Update(); + working_image->ReleaseData(); output = caster->GetOutput(); //-------------------------------------------------------------------- @@ -291,6 +308,7 @@ GenerateOutputInformation() { cropFilter->SetInput(output); cropFilter->SetBackgroundValue(GetBackgroundValue()); cropFilter->Update(); + output->ReleaseData(); output = cropFilter->GetOutput(); StopCurrentStep(output); } @@ -303,6 +321,7 @@ GenerateOutputInformation() { cropFilter->SetLowerBoundaryCropSize(bounds); cropFilter->SetUpperBoundaryCropSize(bounds); cropFilter->Update(); + output->ReleaseData(); output = cropFilter->GetOutput(); } }