vtk image connectivity filter

Hi,

I have labeled 3D image with two different pixel values. I want to apply image connectivity filter to remove the other noises which are creating problems to create a simple surface extraction in the next level.

I could not find any example on image connectivity filter and I am using vtk 5.10 which does not include the function. (screenshot attached).

Could please help me to figure out.

1

I am referring to this.
https://vtk.org/Wiki/VTK/Image_Connectivity

First of all, you need to upgrade to a recent VTK version. It is unreasonable to expect help with using a decade old version.

You can find vtkImageConnectivityFilter documentation here. All VTK filters have tests, which you can use as examples. See the relevant test here. You can find a Python example in 3D Slicer’s “Flood filling” Segment Editor effect. If you have any specific questions you can ask it here.

There is no example for this filter on VTK examples website. It would be great if you could write one (based on what you have learnt and you think could be useful for others who are new to VTK) and contribute it as described here.

Before you implement anything, I would suggest to first create your segmentation workflow in a VTK-based interactive segmentation tool, such as 3D Slicer. Once you know exactly what steps you need to get good-quality segmentation, you can start automating the process.

1 Like

Thank You so much for your response. I updated my vtk with the latest one. But still does not find the library. Is there any specific version is needed to use that library?

I will definitely do that with 3D slicer at first.

Thanks

I would like to share my problem with you little bit elaborately. Maybe, in that case, you can suggest to me better.

I have labeled my model CT image with bone label (150) and skull Foramen label (210). When I applied a multi-material surface extraction. I have got so many islands and noises in the bone surface mesh because there are very small holes within the bone mesh. Before doing the surface extraction I need to make sure that the bone label has no small holes within it. I have attached some screenshots.
I want to fill those small holes so that the shared boundary of two labels stay intact.

1
2

When you segment bones on CT images with simple global thresholding then you typically need to solidify the extracted surface, because cancellous bone average intensity is similar to soft tissues.

You can use Wrap solidify tool in 3D Slicer. The tool is fully implemented using VTK filters, so if you want you can just copy-paste its source code to your application (but most likely you will realize that it’s just more efficient to use the segmentation tools inside Slicer).

For example, hole filling in a dental CT scan:

Brain cavity extraction using the same tool:

If you want to do skull stripping from CT, you can use the CT skull stripping segmentation recipe.

If you need further help with segmenting medical images, please post it on the 3D Slicer forum.

Hi,

I have tried to apply the wrap solidify, it’s not working with my labeled ct data. But when I tried with original data, it’s working. Is that because the labeled data is already segmented?
I was following the steps of the link.

Thanks.

I’m glad it worked well. If you already have a segmented labelmap, you can import that into a segmentation node (right-click on it in Data module). You need to select an image volume as “master volume”. If you don’t want to load your original CT then you can create an empty volume by clicking on the button next to the master volume selector and then click OK. If you have further questions about this, please post on the Slicer forum.

Thank You so much for your response. I updated my vtk with the latest one. But still does not find vtkImageConnectivityFilter library. Is there any specific version is needed to use that library?

Thanks.

I don’t know exactly which Python distributions have which VTK version but this filter is not new, so it should be available in most current versions. What Python distribution do you use?

I am using vtk with c++. Not using python.

In latest VTK versions, you need to select the VTK modules you want to use.

However, before you spend too much time with it, I can tell you that it fills regions very nicely, but it cannot handle holes very well. If you enable its leak prevention mechanism then contours in the resulting labelmap will be kept at a distance from contours in the original labelmap, so details are lost, shapes are changed, which becomes severe when you have holes that are larger than 1-2 voxels. You can give it a try in 3D Slicer’s Flood fill effect to see it for yourself. We had to implement more complicated hole filling mechanisms exactly because this simple filter just cannot cope with holes that commonly occur in medical images.