问题
I have several .vti files . How can I convert .vti files into a standard format of 2D images? I've tried ParaView, but didn't find any option to convert in one of above mentioned formats like JPEG or PNG.
回答1:
In ParaView: load your vti file, then in the File menu click "Save Data..." and chose the image file format you prefer (I tested with PNG, it works).
In Python, this script reads test.vti and saves test.jpg:
import vtk
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName("test.vti")
reader.Update()
image = reader.GetOutput()
writer = vtk.vtkJPEGWriter()
writer.SetInputData(image)
writer.SetFileName("test.jpg")
writer.Write()
来源:https://stackoverflow.com/questions/55258810/convert-vti-files-to-open-it-with-python