<div><div class="gmail_quote">On Wed, Dec 16, 2009 at 12:59 PM, John Smith <span dir="ltr"><<a href="mailto:af3113@yahoo.com">af3113@yahoo.com</a>></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'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->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->GetInput<span>(</span><span>)</span>->GetSpacing<span>(</span>spacing<span>)</span>;<br>point<span>[</span><span>2</span><span>]</span> = imageViewer->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->GetInput<span>(</span><span>)</span>->FindPoint<span>(</span>point<span>)</span>;<br><span>double</span><span></span>* scalarPointer = <span>(</span><span>double</span><span></span>*<span>)</span>imageViewer->GetInput<span>(</span><span>)</span>->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 << "<span>(" << </span>point<span>[</span><span>0</span><span>] << ", "</span> << point<span>[</span><span>1</span><span>] << ", " << </span>point<span>[</span><span>2</span><span>]</span> << "): " << 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'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'll take a look?</div><div><br clear="all">Thanks,<br><br></div><div>David</div></div></div>