How to get the depth of 3D image?

I rendered a 3D image using vtk. The result looks as follows:

I want to get a depth map for abve image. Currently I used vtkWorldPointPicker to pick each pixel on the screen, and then got the real position through vtkWorldPointPicker .GetPickPosition(). But it takes too much time to traverse each pixel in the image.
I was wondering maybe there is an esay way to get the depth map of the image quickly. Any clues would be appreciated.

1 Like

Create a vtkWindowToImageFilter and call SetInputBufferTypeToZBuffer(); then when you fetch the filter’s output image, each pixel should be filled with a depth value.