Search code examples
c++vtkdicomitk

How to use region-growing algorithms to define a region of interest?


I am working on DICOM images (CT scans) & would like to isolate some structures of interest in my picture such as human organs (like the aorta, cf the image enclosed). I am coding in C++ with the help of ITK & VTK.

The bright tube describes a sick aorta and corresponds to the structure that I would like to isolate.

Let's assume these organs have a particular brightness intensity, therefore I can automatically identify them by using a region-growing algorithm (code below). In order to do so, I previously computed some threshold values based on the mean & standard deviation values of the voxels belonging to the organ.

How can I only keep the aorta in my image with the help of ITK/VTK features? I guess that what I'm looking for is a filter that would do the exact opposite of the ITK mask image filter.

Please find the (pseudo) code corresponding to the organ isolation below. I computed a 5 voxels dilation on the result of the region-growing to be sure to include all voxels of the organ and to have a sufficient margin around the organ after cropping.

typedef short InputPixelType;
typedef unsigned char OutputPixelType; 
const int Dimension = 3;

typedef itk::Image< InputPixelType, Dimension > InputImageType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;

// Region growing
typedef itk::ConnectedThresholdImageFilter< InputImagetype, 
OutputImagetype > ConnectedFilterType;

ConnectedFilterType::Pointer connectedThreshold = ConnectedFilterType::New();

connectedThreshold->SetInput(input);
connectedThreshold->SetUpper(upperThreshold);
connectedThreshold->SetLower(lowerThreshold);

//Initializing seed
InternalImagetype::IndexType index;
index[0] = seed_x; 
index[1] = seed_y;
connectedThreshold->SetSeed(index);

// Dilate the resulting region-growing of 5 voxels for safety
typedef itk::BinaryBallStructuringElement< OutputImageType, 
Dimension > StructuringElementType;
typedef itk::BinaryDilateImageFilter< OutputImageType, 
OutputImageType, StruturingElementType > DilateFilterType;

StructuringElementType structuringElement;
structuringElement.SetRadius(5);
structuringElement.CreateStructuringElement();

DilateFilterType::Pointer dilateFilter = DilateFilterType::New();
dilateFilter->SetInput(connectedThreshold->GetOutput());
dilatefilter->SetKernel(structuringElement);

// Saving the results of the RG+dilation
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(dilateFilter->GetOutput());
writer->SetFileName("organ-segmented-with-dilation.mhd");
try {
    writer->Update();
} catch(itk::ExceptionObject& err) {
    std::cerr << "Exception caught! " << err.what() << std::endl;
    return EXIT_FAILURE;
}

// What to do next to crop the input image with this region-growing? 

Any help or remark is welcomed.


Solution

  • For the record, I solved my problem using the ITK mask negated filter, which contrarily to the basic mask filter directly answers the issue.