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.
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();