Help Installing vtkITK module

Hello,
This isn’t exactly a Slicer question, but I thought someone on these forums may be able to help.
I want to use vtkITK.vtkITKIslandMath
However, I would prefer to use it on a regular Python installation instead of 3D Slicer.
Can you pip install the module vtkITK? If so what is the syntax for this?
python -m pip install vtkITK
didn’t work for me.

ITK island math filter may be available on PyPI via ITK or SimpleITK Python package.

If you want to use vtkITK package then you need to use the Python virtual environment provided by Slicer.

1 Like

Thanks. I’ve decided to run this in Slicer. If you don’t mind, could you also let me know how to convert my image, which is a SimpleITK object, into a format that can be accepted by the vtkITKIslandMath filter? And also how to convert the output of this filter back into a SimpleITK object?

You can pass volumes between SimpleITK and Slicer scene using stikUtils. See example here: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Running_an_ITK_filter_in_Python_using_SimpleITK

1 Like

Thanks, unfortunately vtkITKIslandMath only takes vtkAlgorithmOutput as an input, and I’m not sure how to get that.

Since vtkITKIslandMath is derived from vtkSimpleImageToImageFilter, it can use both data (SetInputData()) and connection (SetInputConnection()) as input, just as any other VTK filter.

1 Like

Hi @lassoan, What is vtkITKIslandMath used for when the input is a binary image?

vtkITKIslandMath assigns unique label value to each connected region in an image. See details in its documentation.

1 Like

Does vtk have any similar library? @lassoan

I don’t think VTK has such filter. We only add those ITK filters to vtkITK that do not have an equivalent in VTK.