[Insight-users] accessing vector value from python

Zachary Pincus zpincus at stanford.edu
Wed Apr 5 11:13:56 EDT 2006


One quick note, to clarify what's going on:

When SWIG doesn't know what to do with a pointer or reference, it  
turns it into a name-mangled string containing the pointer's type and  
address. So '_0441d308_p_itk__VectorTfloat_2_t' is a pointer to an  
itk::Vector<float, 2> at memory address 0x0441d308. Unfortunately, as  
Gaetan pointed out, the ITK wrappers don't know what to do with such  
a pointer. (Or actually, even with pointers to simpler things like  
ints and floats, I think.)

WrapITK solves many of these issues, but be aware that it is a work  
in progress so there still may be some similar rough edges. We're  
working on them as fast as we can, and the more people that use it,  
the faster we can find and fix any problems.

As to the licensing, I'm not sure what the current status is.  
Eventually the copyright will be transferred over to the Insight  
Software Consortium, I assume, and it will be licensed under the ITK  
license. Gaetan might have a more useful comment.

Zach



On Apr 5, 2006, at 7:45 AM, Eduardo Suarez wrote:

> When i run this code, i finally get a string. What am i doing wrong?
>
> Thanks,
> -Eduardo
>
> import InsightToolkit as itk
> reader = itk.itkImageFileReaderVF2_New()
> reader.SetFileName('output.mhd')
> reader.Update()
> image = reader.GetOutput()
> image
>    <C itk::Image<(itk::Vector<(float,2)>,2)> instance at
>    _d005d208_p_itk__ImageTitk__VectorTfloat_2_t_2_t>
> ind=itk.itkIndex2()
> ind.SetElement(0, 0)
> ind.SetElement(1, 0)
> pix=image.GetPixel(ind)
> pix
>    '_0441d308_p_itk__VectorTfloat_2_t'
> pix.__class__
>    <type 'str'>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list