[Insight-users] ITK Resample filter python wrapper

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Mon Jun 15 14:25:54 EDT 2009


Le 15 juin 09 à 18:14, ramasa at rpi.edu a écrit :

>
> Hello everyone,

Hi,

>
> I am trying to write a python script (using ITK Python wrappers  
> generated
> using CSwig) to replicate the task done by
> ResampleVolumesToBeIsotropic.cxx in the Examples/Filtering folder. I  
> was
> unsuccessful and the problem comes down to the fact that I am not  
> able to
> set a the tranform object to the resampling filter. The problem can be
> reproduced by the following few commands in the Python prompt:
>
>>>> import InsightToolkit as ITK
>>>> a = ITK.itkResampleImageFilterF3F3_New()
>>>> b = ITK.itkIdentityTransform3_New()
>>>> a.SetTransform(b)
>
> The error I obtain is as follows:
>
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "D:/Adarsh/Insight/bin/bin/Release\itkResampleImageFilter.py",  
> line 299,
> in SetTransform
>    def SetTransform(*args): return
> _itkResampleImageFilter 
> .itkResampleImageFilterF3F3_Pointer_SetTransform(*args)
> TypeError: Type error. Got
> _p_itk__SmartPointerTitk__IdentityTransformTdouble_3u_t_t, expected
> _p_itk__TransformTdouble_3u_3u_t.
>
> Can someone help me identify the problem?


You should either:

* use "a.SetTransform(b.GetPointer())". GetPointer() is required  
because swig is not able to find that an object is of a subclass of  
one other when it is encapsulated in a smart pointer. GetPointer()  
produce a raw pointer, and thus swig can pass the object to your method.

* use wrapitk from google code. It doesn't expose smart pointers in  
python anymore, so there is no problem of that kind.

Regards,

Gaëtan

-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.itk.org
http://www.mandriva.org  http://www.bepo.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090615/1c019680/attachment.pgp>


More information about the Insight-users mailing list