Reputation: 1
I’m a beginner of ITK and VTK.Now I want to use the 3D region growing algorithms to segment specific tissues.I have finished the vulume rendering and could get the voxel index by using vtkImagePlaneWidget.But How to get the world coordinate of the index?
Upvotes: 0
Views: 808
Reputation: 1
Other way to do this: if you have a image volume or 3D image with index (i,j,k). You can get the world coordinates (x,y,z) with:
xo,yo,zo = vtk_volume.GetOrigin()
xs,ys,zs = vtk_volume.GetSpacing()
x = xo + i*sx
y = yo + j*sy
z = zo + k*sz
Upvotes: 0
Reputation: 71
vtkImageData exposes a method called TransformIndexToPhysicalPoint which converts voxel indices to world coordinate.
Called from python, it looks something like this
import vtk
img = vtk.vtkImageData()
img.SetDimensions([256,256,256])
img.SetSpacing([0.5,0.5,0.5])
img.SetOrigin([100,100,100])
physical_coord = [0,0,0] # Placeholder
index_coord = [128,128, 128]
img.TransformContinuousIndexToPhysicalPoint(index_coord, physical_coord)
assert tuple(phyiscal_coord) == (164,164,164)
Upvotes: 0