Bottom Boundary of the lungs

Hi all,
I segmented the lungs in ITK. Now, I need to get the boundary of the most inferior part of the lungs, the same as pink and blue lines shown in the attached image. I am a beginner in ITK and I really need to get this result ASAP. I appreciate it if anyone can help me about writing the codes in this regard such that I can get the result quickly.
In addition to that, how can I find the most left and right and inferior voxel in the coronal view of a 3D image?
images.rar (2.7 KB)

Use iterators, examine values and record leftmost, rightmost etc indices you are interested in.

How can I write the code such that it searches for the maximum indices (since I need to find the inferiormost part) where their pixel values are 1?

Go through the entire image using an iterator, examine each value, and for pixels with value 1 update the current min/max index (iff current index is greater/lesser than max/min).

Do you have any example about it?

Since I do not know how to write that code.

It is similar to finding a maximum value in an array.

This is a specialized “image processing and analysis using ITK” forum, not a learn programming forum. If that is what you need, there are many other resources to use.

Got it, thanks.

Dzenan, can you give us an example of what filter should we use in SimpleITK (not ITK) in order to iterate each image component ?

Here I’ve found a list with all SimpleITK filters: https://simpleitk.readthedocs.io/en/latest/Documentation/docs/source/filters.html

but I don’t know what filter “split” the image into iterators ?

I don’t think SimpleITK exposes iterators. Is that correct @blowekamp @zivy?

The single filter that seem to show/use iterators, seem to be SLICImageFilter, but I don’t know how to extract the iterators from it …

Hello @flaviu2,
@dzenanz’s response is to the point. In SimpleITK you should use operators on the whole image, though you can still iterate through the pixels (very slow when accessed via GetPixel, SetPixel, fast if you don’t need the indexes for pix in img: print(pix))

1 Like