From 667a674794cf667db213d3c03f2d4b5d907ca35d Mon Sep 17 00:00:00 2001 From: Vivien Delmon Date: Wed, 8 Jun 2011 17:31:33 +0200 Subject: [PATCH] Add padding in clitkExtractPatient Add padding around the patient to form one big air area around the patient. ExtractPatient relies on this assumption which was false for dir-labs patients cropped around the ribcage. --- segmentation/clitkExtractPatientFilter.txx | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/segmentation/clitkExtractPatientFilter.txx b/segmentation/clitkExtractPatientFilter.txx index a04232b..74cc2cc 100644 --- a/segmentation/clitkExtractPatientFilter.txx +++ b/segmentation/clitkExtractPatientFilter.txx @@ -35,6 +35,7 @@ #include "itkBinaryMorphologicalOpeningImageFilter.h" #include "itkBinaryBallStructuringElement.h" #include "itkCastImageFilter.h" +#include "itkConstantPadImageFilter.h" //-------------------------------------------------------------------- template @@ -113,9 +114,22 @@ GenerateOutputInformation() { //-------------------------------------------------------------------- // Step 1: StartNewStep("Find low densities areas"); + + // Pad images with air to prevent patient touching the image border + typedef itk::ConstantPadImageFilter PadFilterType; + typename PadFilterType::Pointer padFilter = PadFilterType::New(); + padFilter->SetInput(input); + padFilter->SetConstant(GetUpperThreshold() - 1); + typename InputImageType::SizeType bounds; + for (unsigned i = 0; i < Dim - 1; ++i) + bounds[i] = 1; + bounds[Dim - 1] = 0; + padFilter->SetPadLowerBound(bounds); + padFilter->SetPadUpperBound(bounds); + typedef itk::BinaryThresholdImageFilter BinarizeFilterType; typename BinarizeFilterType::Pointer binarizeFilter=BinarizeFilterType::New(); - binarizeFilter->SetInput(input); + binarizeFilter->SetInput(padFilter->GetOutput()); if (m_UseLowerThreshold) binarizeFilter->SetLowerThreshold(GetLowerThreshold()); binarizeFilter->SetUpperThreshold(GetUpperThreshold()); binarizeFilter ->SetInsideValue(this->GetForegroundValue()); @@ -257,6 +271,17 @@ GenerateOutputInformation() { output = cropFilter->GetOutput(); StopCurrentStep(output); } + else + { + // Remove Padding region + typedef itk::CropImageFilter CropFilterType; + typename CropFilterType::Pointer cropFilter = CropFilterType::New(); + cropFilter->SetInput(output); + cropFilter->SetLowerBoundaryCropSize(bounds); + cropFilter->SetUpperBoundaryCropSize(bounds); + cropFilter->Update(); + output = cropFilter->GetOutput(); + } } //-------------------------------------------------------------------- -- 2.47.1