[vtkusers] Picking a pixel from an image (works, but ...)
John Smith
af3113 at yahoo.com
Wed Dec 16 12:59:26 EST 2009
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091216/9c785781/attachment.htm>
More information about the vtkusers
mailing list