In VTK I am able to use the following snippet to save the render window as an image. However, actually I want to get it directly as a numpy array (without writing then reading).
im = vtkWindowToImageFilter()
writer = vtkPNGWriter()
im.SetInput(renderWindow)
im.Update()
writer.SetInputConnection(im.GetOutputPort())
writer.SetFileName("file.png")
writer.Write()
What is the best way to do this?
vtk.util.numpy_support.vtk_to_numpy:(