Extract points from vtkImageData


My question is how can I extract points from vtkImageData. For example, considering 3D image(labelMap), if in voxels there are 3 voxel values, I would get the coordinates of those voxels.

vtkImageData->getPoint() return the point coordiantes in physical space. However I want the point coordinates in ijk space then convert them to RAS space.

Thank’s in advance

To get the coordinates in index space [ijk], You would use
vtkImageData->TransformPhysicalPointToContinuousIndex(point[3], index[3])

See: https://vtk.org/doc/nightly/html/classvtkImageData.html#aa37a2184cb38394a8828d4998f0628fc

Thank’s for the response. What about if I takes I,J,K voxel coordinates directly? where

vtkImageData-- >GetExtent(Kmin,Kmax,Jmin,Jmax,IMin,Imax)

i in range (kmin, kmax)
j in range (jMin,Jmax)
k in range (iMin,Imax)

That would also work.

There are also a few complete examples in script repository, for example:




Thank’s for your responses.

I will try to clarify more my issue.

I have a label Map (vtkImage Data) on which I have applied “vtkImageLabelOutlines” filter to keep only labelMap boundries.

What I want is to recover the 3D points corresponding to labelMap boundries labelMapBoundry) and store them in vtkPoints array

I am trying athe following test, but I don’t know if it can resolve the issue:

vtkVariant variant = labelMapBoundry->GetPointData()->GetScalars()->GetVariantValue(labelMapBoundry->computePointId(ijk_coords);

then store (i,j,k).

I don’t understand this. You can convert between voxel and physical coordinates as described in the script repository examples I linked above.