[vtkusers] Picking a pixel from an image (works, but ...)

David Doria daviddoria+vtk at gmail.com
Wed Dec 16 13:18:09 EST 2009


On Wed, Dec 16, 2009 at 12:59 PM, John Smith <af3113 at yahoo.com> wrote:

> Dear all,
>
> I have a little problem picking a pixel from a vtkImageViewer2. I use
> vtkPointPicker for that. Here's the procedure I use:
>
> 1.Get mouse location in scene space:
> double point[3];
> picker->GetMapperPosition(point);
>
> 2.Get correct mapped z-location:
> double spacing[3];
> imageViewer->GetInput()->GetSpacing(spacing);
> point[2] = imageViewer->GetSlice() * spacing[2];
>
> 3.Get the actual volume index of the mouse over pixel;
> int index = imageViewer->GetInput()->FindPoint(point);
> double* scalarPointer = (double*)imageViewer->GetInput()->GetScalarPointer
> ();
> double intensity = scalarPointer[index];
>
> 4.Printing the picked pixel coordinates and the pixel intensity:
> cerr << "(" << point[0] << ", " << point[1] << ", " << point[2] << "): "
> << intensity;
>
> The problem I have is that I always get wrong values comparing to other
> programs. Maybe I miss something out.
>
> Thank you in advance.
>
> Regards,
>
> J.
>
>
John,

This is something I've been wanting to look at for a while now. Lets tackle
it.

I created a blank example:
http://www.vtk.org/Wiki/VTK/Examples#Working_with_Images

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?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091216/2db3f7a9/attachment.htm>


More information about the vtkusers mailing list