<div><div class="gmail_quote">On Wed, Dec 16, 2009 at 12:59 PM, John Smith <span dir="ltr">&lt;<a href="mailto:af3113@yahoo.com">af3113@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">Dear all,<br><br>I have a little problem picking a pixel from a vtkImageViewer2. I use vtkPointPicker for that. Here&#39;s the procedure I use:<br>
<br>1.Get mouse location in scene space<span>:<br>double</span> point<span>[</span><span>3</span><span>]</span>;
<div>picker-&gt;GetMapperPosition<span>(</span>point<span>)</span>;</div><br>2.Get correct mapped z-location:<span><br>double</span> spacing<span>[</span><span>3</span><span>]</span>;
<div>imageViewer-&gt;GetInput<span>(</span><span>)</span>-&gt;GetSpacing<span>(</span>spacing<span>)</span>;<br>point<span>[</span><span>2</span><span>]</span> = imageViewer-&gt;GetSlice<span>(</span><span>)</span> * spacing<span>[</span><span>2</span><span>]</span>;</div>
<br>3.Get the actual volume index of the mouse over pixel;<br><div><span>int</span> index = imageViewer-&gt;GetInput<span>(</span><span>)</span>-&gt;FindPoint<span>(</span>point<span>)</span>;<br><span>double</span><span></span>* scalarPointer = <span>(</span><span>double</span><span></span>*<span>)</span>imageViewer-&gt;GetInput<span>(</span><span>)</span>-&gt;GetScalarPointer<span>(</span><span>)</span>;<br>
<span>double</span> intensity = scalarPointer<span>[</span>index<span>]</span>;<br><br>4.Printing the picked pixel coordinates and the pixel intensity:<br>cerr &lt;&lt; &quot;<span>(&quot; &lt;&lt; </span>point<span>[</span><span>0</span><span>] &lt;&lt; &quot;, &quot;</span> &lt;&lt; point<span>[</span><span>1</span><span>] &lt;&lt; &quot;, &quot; &lt;&lt; </span>point<span>[</span><span>2</span><span>]</span> &lt;&lt; &quot;): &quot;  &lt;&lt; intensity<span></span>;<br>
<br>The problem I have is that I always get wrong values comparing to other programs. Maybe I miss something out. <br><br>Thank you in advance.<br><br>Regards,<br><br>J.<br></div><div><br></div></td></tr></tbody></table></blockquote>
<div><br></div><div>John,</div><div><br>This is something I&#39;ve been wanting to look at for a while now. Lets tackle it.</div><div><br></div><div>I created a blank example: </div><a href="http://www.vtk.org/Wiki/VTK/Examples#Working_with_Images">http://www.vtk.org/Wiki/VTK/Examples#Working_with_Images</a><div>
<br></div><div>Can you either send me (the mailing list) your current example or go ahead and put it on the wiki and we&#39;ll take a look?</div><div><br clear="all">Thanks,<br><br></div><div>David</div></div></div>