ImageToVTKImageFilter usage in python

Good morning,
I am back with another (potentially trivial for a non-beginner) problem !

I have an image read by a ImageSeriesReader.
Now I want to pass it through an ImageToVTKImageFilter to get an ImageData and apply some transforms, visualize it, etc.

The thing is, the output of my ImageToVTKImageFilter is always None.

What I did so far:

  • I checked hat the input image is valid by writing it as a vtk file and visualizing it in paraview.
  • I tried to create manually an image and pass it instead as the input. Same result.
  • I printed the filter and got the output you can see below

ImageToVTKImageFilter (0x1920120)
RTTI typeinfo: itk::ImageToVTKImageFilter<itk::Image<short, 3u> >
Reference Count: 1
Modified Time: 1784
Debug: Off
Object Name:
Observers:
none
Inputs:
Primary: (0)
Indexed Inputs:
0: Primary (0)
No Required Input Names
NumberOfRequiredInputs: 0
Outputs:
Primary: (0)
Indexed Outputs:
0: Primary (0)
NumberOfRequiredOutputs: 0
Number Of Threads: 8
ReleaseDataFlag: Off
ReleaseDataBeforeUpdateFlag: On
AbortGenerateData: Off
Progress: 0
Multithreader:
RTTI typeinfo: itk::PoolMultiThreader
Reference Count: 1
Modified Time: 1783
Debug: Off
Object Name:
Observers:
none

Here is the piece of code not working:
itkToVtkFilter = itk.ImageToVTKImageFilter[ImageType].New()
itkToVtkFilter.SetInput(image)
itkToVtkFilter.Update()
volume = itkToVtkFilter.GetOutput()

Do you have an idea of what is wrong here ?
Thanks a lot.
Edern

1 Like