<div dir="ltr"><div><div><div><div><div><div>Hello Fabio,<br><br></div>I was able to use this filter in Python. Here is the commands I typed:<br>In [14]: ImageType=itk.Image[itk.Vector[itk.F,2],2]<br><br>In [15]: source=itk.PhysicalPointImageSource[ImageType].New()<br><br>In [16]: source.SetSize([5,5])<br><br>In [17]: source.SetOrigin([0,0])<br><br>In [18]: source.SetSpacing([.5,.5])<br><br>In [19]: source.Update()<br><br>In [20]: itk.GetArrayFromImage(source)<br>Out[20]: <br>itkndarray([[[ 0. , 0. ],<br> [ 0.5, 0. ],<br> [ 1. , 0. ],<br> [ 1.5, 0. ],<br> [ 2. , 0. ]],<br><br> [[ 0. , 0.5],<br> [ 0.5, 0.5],<br> [ 1. , 0.5],<br> [ 1.5, 0.5],<br> [ 2. , 0.5]],<br><br> [[ 0. , 1. ],<br> [ 0.5, 1. ],<br> [ 1. , 1. ],<br> [ 1.5, 1. ],<br> [ 2. , 1. ]],<br><br> [[ 0. , 1.5],<br> [ 0.5, 1.5],<br> [ 1. , 1.5],<br> [ 1.5, 1.5],<br> [ 2. , 1.5]],<br><br> [[ 0. , 2. ],<br> [ 0.5, 2. ],<br> [ 1. , 2. ],<br> [ 1.5, 2. ],<br> [ 2. , 2. ]]], dtype=float32)<br><br></div><div>It also worked with VectorImages:<br><br>In [22]: ImageType=itk.VectorImage[itk.F,2]<br><br>In [23]: source=itk.PhysicalPointImageSource[ImageType].New()<br><br>In [24]: source.SetOrigin([0,0])<br><br>In [25]: source.SetSize([5,5])<br><br>In [26]: source.SetSpacing([.5,.5])<br><br>In [27]: source.Update()<br><br>In [28]: itk.GetArrayFromImage(source)<br><br></div><div><br></div>To answer your questions:<br></div>1) This filter is only wrapped over image of vectors and vector images. You can have the list of types that are available in Python with itk.PhysicalPointImageSource.GetTypes()<br></div>2) You may have a version of ITK Python for which VectorImage is not wrapped for PyBuffer. You can try to update your ITK Python [1]<br><br></div>Hope this helps,<br></div>Francois<br><div><div><br>[1] <a href="https://github.com/InsightSoftwareConsortium/ITKPythonPackage">https://github.com/InsightSoftwareConsortium/ITKPythonPackage</a><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 28, 2017 at 12:05 PM, D'Isidoro Fabio <span dir="ltr"><<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="DE-CH">
<div class="m_3566153338244404760WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Thank you for your reply.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="m_3566153338244404760MsoListParagraph"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><span>1)<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">I have tried as a first step the following:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">DRRPhy =
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.PhysicalPointImageSource[</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">i<wbr>tk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.Image[</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.Point[</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.F,
Dimension], Dimension]].New()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">But I get the error:
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">KeyError: "itkTemplate : No template (<class 'itkPointPython.itkPointF3'>, 3) for the itk::Image class"
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">sourceImage =
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.PhysicalPointImageSource[</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">i<wbr>tk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.VectorImage[</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.F,
Dimension]].New()<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">sourceImage.SetSize(size)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">sourceImage.SetSpacing(<wbr>spacing)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">sourceImage.SetOrigin(origin)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:green" lang="EN-US">#DRRPhy.SetIndex(start) it does not work, how to set the start index?</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">DRRPhy.SetDirection(direction)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US"><u></u> <u></u></span></p>
<p class="m_3566153338244404760MsoListParagraph"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><span>2)<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">However, using PyBuffer to get a numpy array form that does not work:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">sourceImageArray =
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a" lang="EN-US">itk</span><span style="font-size:9.5pt;font-family:Consolas;color:black" lang="EN-US">.PyBuffer[ImageType].<wbr>GetArrayFromImage(sourceImage)</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">I get the error:
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">AttributeError: '<wbr>itkPhysicalPointImageSourceVIF<wbr>3' object has no attribute 'GetLargestPossibleRegion'<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Am I doing the right thing in point 1) ?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">How could I solve point 2) ?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Thank you !<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Fabio.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> Lowekamp, Bradley (NIH/NLM/LHC) [C] [mailto:<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a><wbr>]
<br>
<b>Sent:</b> Donnerstag, 27. April 2017 23:16<br>
<b>To:</b> D'Isidoro Fabio <<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>><br>
<b>Cc:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
<b>Subject:</b> Re: [ITK] [ITK-users] ITK PyBuffer get physical point coordinates<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi! <u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">You can generate an image of the physical locations of each pixel with the PhysicalPointImageSource filter:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="https://itk.org/Doxygen/html/classitk_1_1PhysicalPointImageSource.html" target="_blank">https://itk.org/Doxygen/html/<wbr>classitk_1_<wbr>1PhysicalPointImageSource.html</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">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.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">After you generate the point image you should be able to convert to with the same method.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">HTH,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Brad<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Apr 27, 2017, at 4:58 PM, D'Isidoro Fabio <<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>> wrote:<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Hallo,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">I know it’s possible to get a numpy array of an itk image with:</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">itk.PyBuffer[ImageType].<wbr>GetArrayFromImage(Image)</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">Is it by any chance also possible to obtain a (flattended) numpy array of the physical coordinates of the image pixels too?</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US">Thank you!</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" lang="EN-US"> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">______________________________<wbr>_______<br>
Powered by<span class="m_3566153338244404760apple-converted-space"> </span></span><a href="http://www.kitware.com/" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954f72">www.kitware.com</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
Visit other Kitware open-source projects at<br>
</span><a href="http://www.kitware.com/opensource/opensource.html" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954f72">http://www.kitware.com/<wbr>opensource/opensource.html</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
</span><a href="http://www.kitware.com/products/protraining.php" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954f72">http://www.kitware.com/<wbr>products/protraining.php</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
</span><a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954f72">http://www.itk.org/Wiki/ITK_<wbr>FAQ</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
</span><a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954f72">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
______________________________<wbr>_________________<br>
Community mailing list<br>
</span><a href="mailto:Community@itk.org" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954f72">Community@itk.org</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="http://public.kitware.com/mailman/listinfo/community" target="_blank"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954f72">http://public.kitware.com/<wbr>mailman/listinfo/community</span></a><u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
<br>______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>