[Insight-users] accessing vector value from python

Eduardo Suarez eduardo at ctm.ulpgc.es
Wed Apr 5 10:22:47 EDT 2006


Thanks a lot,

for a while i believed i was going crazy. What kind of license applies 
to wrapitk?

Regards,
-Eduardo

Gaetan Lehmann wrote:
> 
> Hi Eduardo,
> 
> You're doing nothing wrong, this feature is just not implemented in the  
> current python wrappers.
> 
> WrapITK support that, and will also let you use python sequences to 
> acces  to your data:
> 
> 15> i = itk.Image.VF22.New()
> 
> 16> i.SetRegions(10)
> 
> 17> i.Allocate()
> 
> 18> i.GetPixel([0,2])
> 18> <C itk::Vector<(float,2)> instance at  
> _84c16a09_p_itk__VectorTfloat_2_t>
> 
> 19> i.GetPixel([0,2])[0]
> 19> 2.7494886334130231e-33
> 
> 20> i.SetPixel(0, 1)
> 
> 21> i.GetPixel(0)[1]
> 21> 1.0
> 
> You can get WrapITK from  
> http://voxel.jouy.inra.fr/darcs/contrib-itk/WrapITK/WrapITK.tar.gz.
> An article have also been submited to the insight journal  
> (http://insight-journal.org). It describe the new features which comes  
> with WrapITK.
> 
> Please try it, and send us your comment about what you find good or not
> 
> Regards,
> 
> Gaetan
> 
> 
> On Wed, 05 Apr 2006 14:45:28 +0200, Eduardo Suarez 
> <eduardo at ctm.ulpgc.es>  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'>
> 
> 
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3302 bytes
Desc: S/MIME Cryptographic Signature
Url : http://public.kitware.com/pipermail/insight-users/attachments/20060405/c5c4d0f8/smime-0001.bin


More information about the Insight-users mailing list