[ITK] [ITK-users] ITK PyBuffer get physical point coordinates

D'Isidoro Fabio fisidoro at ethz.ch
Fri Apr 28 12:05:03 EDT 2017


Thank you for your reply.


1)     I have tried as a first step the following:

DRRPhy = itk.PhysicalPointImageSource[itk.Image[itk.Point[itk.F, Dimension], Dimension]].New()

But I get the error:

KeyError: "itkTemplate : No template (<class 'itkPointPython.itkPointF3'>, 3) for the itk::Image class"

So I guess I can’t generate an image with itk.Points as PixelType. Therefore I chose to use a VectorImage as ImageType in Input to the PhysicalPointImageSource.

sourceImage = itk.PhysicalPointImageSource[itk.VectorImage[itk.F, Dimension]].New()
sourceImage.SetSize(size)
sourceImage.SetSpacing(spacing)
sourceImage.SetOrigin(origin)
#DRRPhy.SetIndex(start) it does not work, how to set the start index?
DRRPhy.SetDirection(direction)


2)     However, using PyBuffer to get a numpy array form that does not work:

sourceImageArray = itk.PyBuffer[ImageType].GetArrayFromImage(sourceImage)

I get the error:

AttributeError: 'itkPhysicalPointImageSourceVIF3' object has no attribute 'GetLargestPossibleRegion'


Am I doing the right thing in point 1) ?
How could I solve point 2) ?

Thank you !

Fabio.

From: Lowekamp, Bradley (NIH/NLM/LHC) [C] [mailto:blowekamp at mail.nih.gov]
Sent: Donnerstag, 27. April 2017 23:16
To: D'Isidoro Fabio <fisidoro at ethz.ch>
Cc: insight-users at itk.org
Subject: Re: [ITK] [ITK-users] ITK PyBuffer get physical point coordinates

Hi!

You can generate an image of the physical locations of each pixel with the PhysicalPointImageSource filter:
https://itk.org/Doxygen/html/classitk_1_1PhysicalPointImageSource.html

Very recently added is the SetReferenceImage, which can be use to copy the meta data from one image to the parameters of this filter. If your version is not super recent then you can manually set the Size, Spacing, Origin, Direction and StartIndex.

After you generate the point image you should be able to convert to with the same method.

HTH,
Brad


On Apr 27, 2017, at 4:58 PM, D'Isidoro Fabio <fisidoro at ethz.ch<mailto:fisidoro at ethz.ch>> wrote:

Hallo,

I know it’s possible to get a numpy array of an itk image with:

itk.PyBuffer[ImageType].GetArrayFromImage(Image)

Is it by any chance also possible to obtain a (flattended) numpy array of the physical coordinates of the image pixels too?

Thank you!

_____________________________________
Powered by www.kitware.com<http://www.kitware.com/>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
_______________________________________________
Community mailing list
Community at itk.org<mailto:Community at itk.org>
http://public.kitware.com/mailman/listinfo/community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170428/f90ba51c/attachment-0001.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list