<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Paolo,<div class=""><br class=""></div><div class="">a couple of thoughts from my own experiences on various platforms. I haven’t had any problems with ITK on Ubuntu, when used with the standard system Python 2.7, so some of these might not apply:</div><div class=""><br class=""></div><div class="">Do you happen to have several different Python distributions on your computer? I have seen such crashing when the ITK was built against one distribution and then used in another. I have also had some difficulties with using ITK Python wrapping on Anaconda. It might also be a compiler compatibility problem, ie. if the Python distribution has been compiled with a different compiler than ITK, but I wouldn’t expect this on Ubuntu, as everything is built with the same GNU compilers.</div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">Sami </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 14 Oct 2015, at 17:17, Paolo Zaffino <<a href="mailto:p.zaffino@yahoo.it" class="">p.zaffino@yahoo.it</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class="">
<div class="moz-cite-prefix">Hi Matt and hi all,<br class="">
thank you very much for your help.<br class="">
Unfortunately python crashes (segmentation fault) at the final
phase of these three examples (basically when I try to create an
image):<br class="">
<ol class="">
<li class="">import itk<br class="">
Dimension = 3<br class="">
PixelType = itk.F<br class="">
ImageType = itk.Image[PixelType, Dimension]<br class="">
<br class="">
</li>
<li class="">import itk<br class="">
img = itk.Image.F3.New()<br class="">
<br class="">
</li>
<li class="">import itk<br class="">
pixelType = itk.UC<br class="">
imageType = itk.Image[pixelType, 2]<br class="">
<br class="">
</li>
</ol>
Any idea?<br class="">
Thank you very much again.<br class="">
<br class="">
Best.<br class="">
Paolo<br class="">
<br class="">
<br class="">
<br class="">
On 14/10/2015 16:48, Matt McCormick wrote:<br class="">
</div>
<blockquote cite="mid:CALzTN-TPgJ8w9+mgkUo1iq68=CHXfCikMBbtLt3oEWJyn8gQPA@mail.gmail.com" type="cite" class="">
<pre wrap="" class="">Hi Paolo,
Lassi has some good suggestions. Some additional information:
If you use ITK Git master [1], the Python wrapping builds in half the
time as ITK 4.8.
To create a histogram matching filter, the preferred syntax is:
import itk
Dimension = 3
PixelType = itk.F
ImageType = itk.Image[PixelType, Dimension]
histogramMatching = itk.HistogramMatchingImageFilter[ImageType,
ImageType].New()
Hope this helps,
Matt
[1] <a class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK/Git">http://www.itk.org/Wiki/ITK/Git</a>
On Wed, Oct 14, 2015 at 5:27 AM, Paavolainen, Lassi
<a class="moz-txt-link-rfc2396E" href="mailto:lassi.paavolainen@jyu.fi"><lassi.paavolainen@jyu.fi></a> wrote:
</pre>
<blockquote type="cite" class="">
<pre wrap="" class="">Hi Paolo,
Why you want to import itkImagePython instead of just itk?
import itk
img = itk.Image.F3.New()
should work as previously. Notice that
itk.HistogramMatchingImageFilter()
would not work in any case since you need to define the types as well.
The modular design of ITK 4 should not have effected the interface of ITK
Python wrappings in anyway. If I'm wrong then maybe someone can correct me.
So I would first check that you are able to import itk and load some filter.
If not, then check that all shared libs are in search path.
Cheers,
Lassi
________________________________
From: Insight-users [<a class="moz-txt-link-abbreviated" href="mailto:insight-users-bounces@itk.org">insight-users-bounces@itk.org</a>] on behalf of Paolo
Zaffino [<a class="moz-txt-link-abbreviated" href="mailto:p.zaffino@yahoo.it">p.zaffino@yahoo.it</a>]
Sent: Wednesday, October 14, 2015 11:51
To: <a class="moz-txt-link-abbreviated" href="mailto:insight-users@itk.org">insight-users@itk.org</a>
Subject: [ITK-users] Python wrapping issue
Dear ITK community,
I compiled ITK 4.8 into an Ubuntu 14.04 machine enabling also the python
wrapping.
Compiling the code took really a while and I had to restart the make phase
more than one time since it crashed without any apparently reason.
Finally when the make step was over I executed the make install command.
If I open ipython and I type "import itkImagePython" it returns
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-dfd82b0a3e37> in <module>()
----> 1 import itkImagePython
/usr/local/lib/ITK-4.8/Python/itkImagePython.py in <module>()
30 fp.close()
31 return _mod
---> 32 _itkImagePython = swig_import_helper()
33 del swig_import_helper
34 else:
/usr/local/lib/ITK-4.8/Python/itkImagePython.py in swig_import_helper()
22 fp, pathname, description =
imp.find_module('_itkImagePython', [dirname(__file__)])
23 except ImportError:
---> 24 import _itkImagePython
25 return _itkImagePython
26 if fp is not None:
ImportError: No module named _itkImagePython
but if I run "import ITKRegionGrowingPython" it works.
In addition, after importing ITKRegionGrowingPython also itkImagePython
works!
I think the path is correctly set, since I see
/usr/local/lib/ITK-4.8/Python.
I also noted that in the "compiledFolder/lib" I see:
ITKRegionGrowingPython.py and _ITKRegionGrowingPython.so
itkImagePython.py but NOT _itkImagePython.so
Do you have any idea?
Furthermore, is it the syntax itk.something still valid or it has been
replaced by separate submodules?
Because if I run
hm=itk.HistogramMatchingImageFilter()
I get
UnboundLocalError: local variable 'module' referenced before assignment
Thank you very much.
Regards.
Paolo
_____________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com/">www.kitware.com</a>
Visit other Kitware open-source projects at
<a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Kitware offers ITK Training Courses, for more information visit:
<a class="moz-txt-link-freetext" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a>
Please keep messages on-topic and check the ITK FAQ at:
<a class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a>
</pre>
</blockquote>
<pre wrap="" class=""></pre>
</blockquote>
<br class="">
</div>
_____________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at<br class=""><a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Kitware offers ITK Training Courses, for more information visit:<br class="">http://www.kitware.com/products/protraining.php<br class=""><br class="">Please keep messages on-topic and check the ITK FAQ at:<br class="">http://www.itk.org/Wiki/ITK_FAQ<br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class="">http://public.kitware.com/mailman/listinfo/insight-users<br class=""></div></blockquote></div><br class=""></div></body></html>