i’m using Itk 5.0.1 with Vtk 8.2 copiled by myself with itkVtkGlue and python wrapping on Windows, both static. When i call ImageToVTKImageFilter in python, it returns None.
I have Itk 5.0.1 and Vtk 8.2 compiled on linux for C++ working correctly with itkVtkGlue. Also have Itk 4.13.2 with Vtk 8.2 compiled on windows for python and working correctly with itkVtkGlue.
Tried with ITK 5.0.1 and VTK 8.1.2, VTK with shared build this time, it happens the same problem
Temporal solution: As i use python as lab and the final code it’s in C++, i use a temporal folder to save itk image as DICOM, then open those DICOM with vtk. This way ensures all spatial information is preserved. I know it’s not a proper way to do it, but maybe it can help those with the same problem until a solution is found. The code it’s:
if itk.Version.GetITKMajorVersion() == 5: #Patch to solve ImageToVTKImage Filter problem with itk
temporalPath = os.path.join(outputPath, "tempExpObj")
if os.path.exists(temporalPath) and os.path.isdir(temporalPath):
shutil.rmtree(temporalPath)
os.makedirs(temporalPath, exist_ok=True)
saveSeveralDcm(itkImage, temporalPath , "", itkReader)
vtkPoly = readDicomVtk(temporalPath)
vtkPoly = imageToObj(vtkPoly)
Solved the issue, now ImageToVTKImageFilter work as intended.
I document here the changes i think led to it working and important flags.
Shared vtk worked great, thanks Matt.
Win itk 5
cmake_Thread_libs = -lpthread
Win vtk 8.2
build_shared_libs = enabled
cmake_Thread_libs = -lpthread
Module_vtkPython = enabled
Module_vtkWrappingPythonCore = enabled //Same as before but important
VTK_USE_SYSTEM_LIBRARIES = enabled
VTK_WRAP_PYTHON = enabled //Same as before but important