[Insight-users] Python & itk : How to print (or use) the value of a pixel in a dicom slice

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Thu Mar 30 09:20:37 EST 2006


Hi Vincent,

Sorry, you'll see me several times if you play with python wrappers, and  
most of the time to talk about WrapITK :-)

with the current wrappers, references to values are not wrapped and,  
unless I missed something, not usable. In WrapITK, the references are  
wrapped and fully usable in python.
You can also use a python sequence instead of an ITK object to give the  
pixel index, which is more convenient.
Here is an example (in python interpreter):

2> import itk

3> reader =  
itk.ImageFileReader.IUC3.New(FileName="/home/glehmann/analyse/granex/emb-01ZOOM.tif")

4> reader.Update()

5> reader.GetOutput().GetPixel([10, 3, 5])
5> 6

6> reader.GetOutput().GetPixel([0, 0, 0])
6> 7


Regards,

Gaetan


On Thu, 30 Mar 2006 11:51:54 +0200, Vincent Page <vpage at univ-ag.fr> wrote:

> Hi,
>
> I m new to python and ITK and have the following problem :
> I want to print the value of a pixel in a Dicom slice...
>
> What I do is the following :
>
> ----------------------------------
> reader = itkImageFileReaderUS2_New()
> dicomIO = itkGDCMImageIO_New()
> reader.SetImageIO( dicomIO.GetPointer() )
> reader.SetFileName( "im_0694" )
>
> reader.Update()
> image = reader2.GetOutput()
>
> seedIntensity = image.GetPixel(seedPosition)
> print seedIntensity
> -----------------------------------
> the result is :
> _3cfdc9aeaa2a0000_p_unsigned_short
>
> Which, I guess, means that seedIntensity is a pointeur on unsigned short.
> If it is, how can I use the value of a pointeur in python, where  
> explicit pointeurs
> doesn't exist (as far as I know)
>
> Uuh...I went through the ItkSoftwareGuide but didn't find any help there.
>
> Thanks a lot.
>
> Vincent Pagé.
>
>
>
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



-- 
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


More information about the Insight-users mailing list