Apply Region Growing Segmentation Filter Multiple Times

Hello,

I am currently sementing the trachea with ConnectedThresholdImageFilter. Several authors segment the trachea using explosion controlled region growing (eg. “Automatic lung segmentation from thoracic computed tomography scans using a hybrid approach with error detection”). That is, the apply the growing algorithm multiple times changing the threshold and when they detect an “growth explosion” (usually two times the number of segmented pixels), they set the “optimal” threshold.

I was wondering how could I apply the ConnectedThresholdImageFilter multiple times. The problem is that the setUpper and setLower thresholds are const and I can’t change them.

Thanks,

Rafael

You can invoke SetUpper and SetLower multiple times. Pseudocode:

auto filter = ConnectedThresholdImageFilter::New();
for i:
  filter->SetUpper(100+i*10);
  filter->Update();
  iResult = filter->GetOutput();
  // count voxels, whatever
  if (condition)
    break; // exit the for loop
// now compute optimal upper and lower threshold
filter->SetUpper(optimal);
filter->Update();
optimalResult = filter->GetOutput();

I used filter->getUpper() and the values of the thresholds do indeed change. But the segmented image is always the same.

What happens if you move the creation of the filter inside the for loop?

for i:
  auto filter = ConnectedThresholdImageFilter::New();
  filter->SetUpper(100+i*10);
  filter->Update();
  iResult = filter->GetOutput();
  // count voxels, whatever
  if (condition)
    break; // exit the for loop
// now compute optimal upper and lower threshold
auto filter = ConnectedThresholdImageFilter::New();
filter->SetUpper(optimal);
filter->Update();
optimalResult = filter->GetOutput();
1 Like


These photos don’t tell me whether the code worked, nor whether you are satisfied.

it worked

2 Likes

thanks!

1 Like