开发者

Going from numpy array to itk Image

开发者 https://www.devze.com 2023-01-22 12:24 出处:网络
I have a numpy array and want to convert it into an ITK image for further processing.How do I do this without using the PyBuffer extension to WrapITK.I can\'t use that because I get a bunch of errors

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

.../E开发者_如何学JAVAxternalProjects/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 an idea about either how to fix the compilation errors or another way to convert my python objects.


Just change

int dimensions[ ImageDimension ];

to

npy_intp dimensions[ ImageDimension ];

and recompile.


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

There is much information at www.simpleitk.org.

The source code and much documentation can be found at http://www.github.com/SimpleITK.


Clone the PyBuffer repository in your ITK source tree at Modules/External. Then enable it in your CMake configuration.

0

精彩评论

暂无评论...
验证码 换一张
取 消