Transition from numpy array to itk Image

I have a numpy array and you want to convert it to an ITK image for further processing. How to do this without using the PyBuffer extension for WrapITK. I cannot use this because when compiling I get a bunch of errors:

.../ExternalProjects/PyBuffer/itkPyBuffer.txx: In static member function ‘static PyObject* itk::PyBuffer<TImage>::GetArrayFromImage(TImage*) [with TImage = itk::Image<float, 2u>]’:
.../ExternalProjects/PyBuffer/wrap_itkPyBufferPython.cxx:1397:   instantiated from here
.../ExternalProjects/PyBuffer/itkPyBuffer.txx:64: error: cannot convert ‘int*’ to ‘npy_intp*’ in argument passing

I could use the idea of ​​how to fix compilation errors or another way to convert my python objects.

+3
source share
3 answers

Just change

int dimensions[ ImageDimension ];

to

npy_intp dimensions[ ImageDimension ];

and recompile.

+2
source

You may be very interested in the recent SimpleITK work that is taking place.

Www.simpleitk.org has a lot of information.

http://www.github.com/SimpleITK.

+1

PyBuffer ITK /External. CMake.

0
source

Source: https://habr.com/ru/post/1771830/


All Articles