[vtkusers] VtkResliceImageViewer cordinate system (world and display)
sfaisalali91
sfaisal.ali91 at gmail.com
Tue Nov 27 05:04:29 EST 2018
I guess i got the solution :) took a while for understanding the
implementation. here is the solution to convert image cordinates to world
cordinates.
vtkIdType ptId = this->ImageData->FindPoint(q);
if (ptId == -1)
{
return 0;
}
double closestPt[3];
this->ImageData->GetPoint(ptId, closestPt);
double origin[3];
this->ImageData->GetOrigin(origin);
double spacing[3];
this->ImageData->GetSpacing(spacing);
int extent[6];
this->ImageData->GetExtent(extent);
int iq[3];
int iqtemp;
for (int i = 0; i < 3; ++i)
{
// compute world to image coords
iqtemp = vtkMath::Round((closestPt[i] - origin[i]) / spacing[i]);
// we have a valid pick already, just enforce bounds check
iq[i] = (iqtemp < extent[2 * i]) ? extent[2 * i] : \
((iqtemp > extent[2 * i + 1]) ? extent[2 * i + 1] : iqtemp);
// compute image to world coords
q[i] = iq[i] * spacing[i] + origin[i];
CurrentWorldPosition[i] = q[i];
this->CurrentPosition[i] = iq[i];
}
std::cout << "Image to world:" << q[0] << ", " << q[1] << ", " << q[2] <<
std::endl;
vtkImageCoordinateWidget helped me with the implementation :) Thank you.
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list