[ITK-users] ITK Python: numpy to itk image (and viceversa)

D'Isidoro Fabio fisidoro at ethz.ch
Sun Apr 2 17:17:50 EDT 2017


Hallo,

I use ITK with Python Wrap. I need to interface my Python code with a Cython-wrapped C++ code that takes only numpy array as input and returns numpy array as output.

Hence, I need to convert the Python itk images into numpy array to be given as input to the wrapped C++ code, and then convert the numpy array in output from the wrapped C++ code back into python itk images.

Question 1) How can I do that in an efficient way? I found some posts on itk.PyBuffer but I could not find anywhere any reference on how to install it on my itk wrap build.

Question 2) The purpose of writing a part of my algorithm in C++ is to speed up the code. If the conversion between python itk images and numpy arrays is slow, I would lose all the speed gain obtained with the C++ implementation. Are there better ways to deal with that?

Thank you,

Fabio.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170402/d659628b/attachment.html>


More information about the Insight-users mailing list