itk.ImageToVTKImageFilter crashing Python

After several gooling and research on code, I was able to use itk.ImageToVTKImageFilter by using my own built ITK source code. For those whose are new comer like me, hope this help you. First of all, I compile source code of ITK release version (ITK Release). Note that I tried the ITK Github (ITK Github), but did not succeed. So I recommend you to compile with Release version. For VTK source code, I also used the the Release version 8.2, not the Github code. The next step I did is to enable the ITK VTK Glue in CMakeCache to ON,adn ITK_WRAP_PYTHON to ON. like this:

╭─phongtd@nguyenth ~/workingspace/InsightToolkit-5.0.1/build_other
╰─$ grep Module_ITKVtkGlue CMakeCache.txt
Module_ITKVtkGlue:BOOL=ON
//ADVANCED property for variable: Module_ITKVtkGlue
Module_ITKVtkGlue-ADVANCED:INTERNAL=1

╭─phongtd@nguyenth ~/workingspace/InsightToolkit-5.0.1/build_other
╰─$ grep PYTHON CMakeCache.txt
ITK_WRAP_PYTHON:BOOL=ON
ITK_WRAP_PYTHON_LEGACY:BOOL=ON
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
PYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6m
PYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.6m.so
PYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND
ITK_WRAP_PYTHON_BINARY_DIR:INTERNAL=/home/phongtd/workingspace/InsightToolkit-5.0.1/build_other/Wrapping/Generators/Python
ITK_WRAP_PYTHON_SOURCE_DIR:INTERNAL=/home/phongtd/workingspace/InsightToolkit-5.0.1/Wrapping/Generators/Python
//ADVANCED property for variable: PYTHON_EXECUTABLE
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_INCLUDE_DIR
PYTHON_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY
PYTHON_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY_DEBUG
PYTHON_LIBRARY_DEBUG-ADVANCED:INTERNAL=1

On this step, I encountered many issues which I asked on the thread https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/10. Do the same thing on that thead you can compile the ITK with Python enabled.

The last step is to run the example. Before doing that, I set the PYTHONPATH variable to point to my ITK build like this:

export PYTHONPATH=/home/phongtd/workingspace/InsightToolkit-5.0.1/build_other/Wrapping/Generators/Python:$PYTHONPATH

And finally, the work is done without any issues.

1 Like