<html><head><meta http-equiv="Content-Type" content="text/html charset=GB2312"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I am not familiar with the Python(x,y) distribution. The "arrayobject.h" header is part of numpy. You need see if you can find this file on your system, if you can not you should look for some type of development package for your Python distribution. The cmake looks like it does the correct thing[1] to locate the numpy header. You may need to manually set PYTHON_NUMARRAY_INCLUDE_DIR if it's not set correctly.<div><br></div><div><br></div><div>Brad</div><div><br></div><div>[1] <a href="https://github.com/tobiasmaier/itkPyBuffer/blob/master/itk-module-init.cmake">https://github.com/tobiasmaier/itkPyBuffer/blob/master/itk-module-init.cmake</a> <div><br></div><div><br><div><div>On Jan 27, 2014, at 11:48 PM, Guo Hengkai <<a href="mailto:guohengkaighk@gmail.com">guohengkaighk@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><div dir="ltr"><div><div><div><div><div><div>Hello Brad, <br><br></div>Thank you for your respond. And I agree with you. But when building the PyBuffer, I fail in compiling it. <br><br></div>My environment is Win7 64bit + ITK4.4.2 + Python2.7.3 + VS2010(32bit). And because I failed in wrapping with python in ITK (error: '__noop' was not declared in this scope), I just used Pythonxy (<a href="http://code.google.com/p/pythonxy/" target="_blank">http://code.google.com/p/pythonxy/</a>) instead. <br>
<br></div>I added PyBuffer in the directory "/Modules/External/" and tried to compile the ITK again in VS2010. But this time I got the error information below:<br><br>5> In file included from D:/Develop/bin/InsightToolkit/Wrapping/Modules/ITKBufferConvertion/itkPyBuffer.cxx:21:<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:31:25: error: arrayobject.h: No such file or directory<br>5> In file included from D:/Develop/bin/InsightToolkit/Wrapping/Modules/ITKBufferConvertion/itkPyBuffer.cxx:21:<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:97: error: 'NPY_DOUBLE' was not declared in this scope<br>5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:98: error: 'NPY_FLOAT' was not declared in this scope<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:100: error: 'NPY_COMPLEX64' was not declared in this scope<br>5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:101: error: 'NPY_COMPLEX128' was not declared in this scope<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:103: error: 'NPY_LONGLONG' was not declared in this scope<br>5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:104: error: 'NPY_ULONGLONG' was not declared in this scope<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:106: error: 'NPY_LONG' was not declared in this scope<br>5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:107: error: 'NPY_ULONG' was not declared in this scope<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:109: error: 'NPY_INT' was not declared in this scope<br>5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:110: error: 'NPY_UINT' was not declared in this scope<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:112: error: 'NPY_USHORT' was not declared in this scope<br>5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:113: error: 'NPY_SHORT' was not declared in this scope<br>
5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:115: error: 'NPY_BYTE' was not declared in this scope<br>5> D:/Develop/src/InsightToolkit-4.4.2/Modules/External/itkPyBuffer/include/itkPyBuffer.h:116: error: 'NPY_UBYTE' was not declared in this scope<br>
<br></div>Do you have any idea? Should I change to VS2008 because someone said that it would not be possible because python 2.7.3 was not compiled with VS10 (<a href="http://permalink.gmane.org/gmane.comp.lib.itk.user/38599" target="_blank">http://permalink.gmane.org/gmane.comp.lib.itk.user/38599</a>)?<br>
<br></div>Thank you!<br></div>Hengkai<br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-01-27 Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
It's been a little bit since I did this. But just used numpy/PyBuffers to convert between SimpleITK and WrapITK. I added the following repository as an External module when I built WrapITK:<br>
<br>
<a href="https://github.com/tobiasmaier/itkPyBuffer" target="_blank">https://github.com/tobiasmaier/itkPyBuffer</a><br>
<br>
That gave me the needed numpy conversion needed to get an image out of WrapITK. While SimpleITK has the GetImageFromArray and GetArrayFromImage methods.<br>
<br>
This does solve the problem of converting between the two wrapping layers. You are looking for a more efficient direct conversion? Why does this not direcly solve your problem? Due to some of SimpleITK's lazy copying, you may get some unexpected behavior by heavily mixing between the two. So there are going to be some usage complication in mixing the two. But it should be possible to write some SWIG interface code to better integrate the two. I would hope that it couple be done with out introducing a dependency directly between the two. If you get an idea or a solution here please let me know.<br>
<br>
Brad<br>
<br>
On Jan 27, 2014, at 8:18 AM, Hengkai Guo <<a href="mailto:guohengkaighk@gmail.com">guohengkaighk@gmail.com</a>> wrote:<br>
<br>
> Dear all,<br>
><br>
> I'm now using SimpleITK in Python. When combining itk with it, I had a problem.<br>
><br>
> I know the way to implement the conversion between itk image and SimpleITK<br>
> image in C++, which is an example in SimpleITK (Examples/ITKIntegration.cxx).<br>
><br>
> //<br>
> // Extract the itk image from the SimpleITK image<br>
> //<br>
> InternalImageType::Pointer itkImage =<br>
> dynamic_cast <InternalImageType*>( image.GetITKBase() );<br>
> ...<br>
> //<br>
> // Return to the simpleITK setting by making a SimpleITK image using the<br>
> // output of the blur filter.<br>
> //<br>
> sitk::Image blurredImage = sitk::Image( blurFilter->GetOutput() );<br>
><br>
> But in Python, when I used "sitk.Image(itkImage)" in which itkImage is an<br>
> itkImage, I got an error "this = _SimpleITK.new_Image(*args)<br>
> NotImplementedError: Wrong number or type of arguments for overloaded<br>
> function 'new_Image'". And in python it's impossible to convert the type<br>
> like "dynamic_cast" in C++.<br>
><br>
> There's one possible solution for this, which use PyBuffer to convert<br>
> itkImage into numpy array and then use SimpleITK to convert array into<br>
> SimpleITK image finally. But I fail in building the itkPyBuffer. And I think<br>
> this method isn't direct to solve this problem.<br>
><br>
> I have tried my best to search in the Internet, but found nothing. Can you<br>
> help me to convert the C++ code into available python code? Thank you.<br>
><br>
><br>
> _____________________________________<br>
> Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br><p>Guo Hengkai (Undergraduate) </p><p>郭亨凯 (本科生)<br>Dept. of Biomedical Engineering<br>School of Medicine,Tsinghua Univ.</p><p>清华大学,医学院,生物医学工程系<br>Beijing, China 中国,北京</p>
</div>
</blockquote></div><br></div></div></body></html>