How to get the right 3D world position for the 2d point selected on DICOM slice?
In our application, we have 3 2d views using vtkImageViewer2 to display the sagittal, coronal and axial view of the DICOMs, and we have another view for the generated 3D model. Now I want to achieve the requirement below:
If user click a point on one slice on the 2D view, I need to get the corresponding 3D point on the 3D model view. If user click a point on the 3D model view, I need to get the corresponding 2D point and slice number.
How to achieve that?
Powered by www.kitware.com
Re: How to get the right 3D world position for the 2d point selected on DICOM slice?
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.
x = imageViewer->GetSlice();
y = vtkMath::Round(pos / spacing);
z = vtkMath::Round(pos / spacing);
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 and pos it's pos and pos)