[vtkusers] How to get the right 3D world position for the 2d point selected on DICOM slice?

Andaharoo Andx_roo at live.com
Thu Jun 15 13:40:23 EDT 2017


I've been using vtkPicker to get the point on the image plane. Basically you
give it the actor, call pick, and it gives you the point on the plane. If
you want to convert that point to your image coordinates you can divide by
the image spacing and round.

http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/PickingAPixel2 this is a
good example but has one error in it. I'd suggest something more like this
when calculating the final point.

x = imageViewer->GetSlice();
y = vtkMath::Round(pos[1] / spacing[1]);
z = vtkMath::Round(pos[2] / spacing[2]);

As you can see in the example, depending on your orientation this changes.
But they didn't account for images with spacing that isn't 1. And there is a
typo I fixed in the orientation example I provided above. (instead of pos[0]
and pos[1] it's pos[1] and pos[2])



--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-get-the-right-3D-world-position-for-the-2d-point-selected-on-DICOM-slice-tp5743657p5743659.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list