How to find voxel with specific ijk coordinates ( for example, voxel (205, 140, 52) ) on an 3D image?( location of the voxel in the image)
I think I misunderstood the question in my first resposne-- you want to convert from an index to spatial coordinates based on the image voxel size.
Here’s a way in the python console:
node = getNode("the name of your volume node")
imageData = node.GetImageData() # Get the underlying vtkImageData
p = [0,0,0]
imageData.TransformContinuousIndexToPhysicalPoint(205,140,52, p) # Stores answer in p
print(p)
See vtkImageData::TransformContinuousIndexToPhysicalPoint
IDK if there’s some other way to get this without the console
It is possible to see this information interactively in the Data Probe (typically present in the lower left of the screen) as well.
The 3D spatial coordinates of the point the mouse is hovering over are shown in the top line (in the screenshot above the RAS coordinates of this point would be (-58.2, 12.4, -3.8)) and the voxel IJK index for the foreground, background, and label images voxels under the mouse focal point are shown below that. For example, in the screenshot, the voxel of the volume named ParcT1 with IJK coordinate (232,257,37) is located at (-58.2, 12.4, -3.8) in the world coordinate system.
This can be handy for cross-referencing, but it requires you to manually navigate to the point you are interested in, so for most purposes you probably want something more like @ebrahim 's solution.