本文整理汇总了Python中vtk.vtkRenderLargeImage函数的典型用法代码示例。如果您正苦于以下问题:Python vtkRenderLargeImage函数的具体用法?Python vtkRenderLargeImage怎么用?Python vtkRenderLargeImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkRenderLargeImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkRenderLargeImage(), 'Processing.',
(), ('vtkImageData',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
示例2: takeSimShot
def takeSimShot(self, fileName):
# print MODULENAME,' takeSimShot: fileName=',fileName
# DON'T REMOVE!
# Better quality
# Passes vtkRenderer. Takes actual screenshot of the region within the widget window
# If other application are present within this region it will shoot them also
renderLarge = vtk.vtkRenderLargeImage()
renderLarge.SetInput(self.graphicsFrameWidget.ren)
renderLarge.SetMagnification(1)
# We write out the image which causes the rendering to occur. If you
# watch your screen you might see the pieces being rendered right
# after one another.
# writer = vtk.vtkPNGWriter()
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(renderLarge.GetOutputPort())
print MODULENAME,"takeSimShot(): vtkPNGWriter, fileName=",fileName
writer.SetFileName(fileName)
print 'TRYING TO WRITE ',fileName
writer.Write()
print 'WROTE ',fileName
示例3: write_image
def write_image(self, filename="image.png", magnification=1,
image_format="png"):
"""
Save render window to an image.
Arguments:
filename:
filename to save to. Defaults to image.png.
magnification:
magnification. Use it to render high res images.
image_format:
choose between jpeg, png. Png is the default.
"""
render_large = vtk.vtkRenderLargeImage()
render_large.SetInput(self.ren)
if image_format == "jpeg":
writer = vtk.vtkJPEGWriter()
writer.SetQuality(80)
else:
writer = vtk.vtkPNGWriter()
render_large.SetMagnification(magnification)
writer.SetFileName(filename)
writer.SetInputConnection(render_large.GetOutputPort())
self.ren_win.Render()
writer.Write()
del render_large
示例4: write_picture
def write_picture(self, magnify, fname):
ren = self.getRenderer()
assert ren is not None
renderLarge = vtk.vtkRenderLargeImage()
renderLarge.SetInput(ren)
renderLarge.SetMagnification(magnify)
rotation = 'x'
self.set_rotation(rotation)
lfname = fname.lower()
if lfname.endswith('.png'):
writer = vtk.vtkPNGWriter()
elif lfname.endswith('.jpeg'):
writer = vtk.vtkJPEGWriter()
elif lfname.endswith('.tiff'):
writer = vtk.vtkTIFFWriter()
elif lfname.endswith('.ps'):
writer = vtk.vtkPostScriptWriter()
else:
writer = vtk.vtkPNGWriter()
writer.SetInput(renderLarge.GetOutput())
writer.SetFileName(fname)
writer.Write()
示例5: writeLargeFrame
def writeLargeFrame( myscreen, w2if, lwr, n , zoom=1):
renderlarge = vtk.vtkRenderLargeImage()
renderlarge.SetInput( myscreen.ren )
renderlarge.SetMagnification(zoom)
writer = vtk.vtkPNGWriter()
writer.SetFileName("large_frame.png")
writer.SetInputConnection( renderlarge.GetOutputPort() )
writer.Write()
print "Wrote large frame!"
示例6: OnExportPicture
def OnExportPicture(self, pubsub_evt):
Publisher.sendMessage('Begin busy cursor')
view_prop_list = []
for slice_data in self.slice_data_list:
view_prop_list.append(slice_data.box_actor)
self.ren.RemoveViewProp(slice_data.box_actor)
id, filename, filetype = pubsub_evt.data
dict = {"AXIAL": const.AXIAL,
"CORONAL": const.CORONAL,
"SAGITAL": const.SAGITAL}
if id == dict[self.orientation]:
if filetype == const.FILETYPE_POV:
renwin = self.interactor.GetRenderWindow()
image = vtk.vtkWindowToImageFilter()
image.SetInput(renwin)
writer = vtk.vtkPOVExporter()
writer.SetFilePrefix(filename.split(".")[0])
writer.SetRenderWindow(renwin)
writer.Write()
else:
ren = self.slice_data.renderer
#Use tiling to generate a large rendering.
image = vtk.vtkRenderLargeImage()
image.SetInput(ren)
image.SetMagnification(1)
image.Update()
image = image.GetOutput()
# write image file
if (filetype == const.FILETYPE_BMP):
writer = vtk.vtkBMPWriter()
elif (filetype == const.FILETYPE_JPG):
writer = vtk.vtkJPEGWriter()
elif (filetype == const.FILETYPE_PNG):
writer = vtk.vtkPNGWriter()
elif (filetype == const.FILETYPE_PS):
writer = vtk.vtkPostScriptWriter()
elif (filetype == const.FILETYPE_TIF):
writer = vtk.vtkTIFFWriter()
filename = "%s.tif"%filename.strip(".tif")
writer.SetInputData(image)
writer.SetFileName(filename)
writer.Write()
for actor in view_prop_list:
self.ren.AddViewProp(actor)
Publisher.sendMessage('End busy cursor')
示例7: key_press
def key_press(obj,event):
key = obj.GetKeySym()
if key=='s' or key=='S':
print('Saving image...')
renderLarge = vtk.vtkRenderLargeImage()
renderLarge.SetInput(ren)
renderLarge.SetMagnification(png_magnify)
renderLarge.Update()
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(renderLarge.GetOutputPort())
writer.SetFileName('fvtk.png')
writer.Write()
print('Look for fvtk.png in your current dir.')
示例8: WritePNG
def WritePNG(ren, fn, magnification = 1):
'''
Save the image as a PNG
:param: ren - the renderer.
:param: fn - the file name.
:param: magnification - the magnification, usually 1.
'''
renLgeIm = vtk.vtkRenderLargeImage()
imgWriter = vtk.vtkPNGWriter()
renLgeIm.SetInput(ren)
renLgeIm.SetMagnification(magnification)
imgWriter.SetInputConnection(renLgeIm.GetOutputPort())
imgWriter.SetFileName(fn)
imgWriter.Write()
示例9: takeSimShot
def takeSimShot(self, fileName):
renderLarge = vtk.vtkRenderLargeImage()
renderLarge.SetInput(self.graphicsFrameWidget.ren)
renderLarge.SetMagnification(1)
# We write out the image which causes the rendering to occur. If you
# watch your screen you might see the pieces being rendered right
# after one another.
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(renderLarge.GetOutputPort())
# # # print "GOT HERE fileName=",fileName
writer.SetFileName(fileName)
writer.Write()
示例10: WritePMG
def WritePMG(ren, fn, magnification=1):
"""
Save the image as a PNG
:param ren: The renderer.
:param fn: The file name.
:param magnification: The magnification, usually 1.
"""
renLgeIm = vtk.vtkRenderLargeImage()
imgWriter = vtk.vtkPNGWriter()
renLgeIm.SetInput(ren)
renLgeIm.SetMagnification(magnification)
imgWriter.SetInputConnection(renLgeIm.GetOutputPort())
imgWriter.SetFileName(fn)
imgWriter.Write()
示例11: exportScreenshot
def exportScreenshot(self, filename):
"""
Save screenshot of the render window into a PNG file.
@param filename: the name of the file
@type filename: str
"""
self.updateRenderWindow()
w2i = vtk.vtkRenderLargeImage()
writer = vtk.vtkPNGWriter()
w2i.SetMagnification(2)
w2i.SetInput(self.renderer)
w2i.Update()
writer.SetInputConnection(w2i.GetOutputPort())
writer.SetFileName(filename)
writer.Write()
示例12: key_press
def key_press(obj, event):
key = obj.GetKeySym()
if key == 's' or key == 'S':
print('Saving image...')
renderLarge = vtk.vtkRenderLargeImage()
if vtk.VTK_MAJOR_VERSION <= 5:
renderLarge.SetInput(renderer)
else:
renderLarge.SetInputData(renderer)
renderLarge.SetMagnification(png_magnify)
renderLarge.Update()
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(renderLarge.GetOutputPort())
writer.SetFileName('trimesh_save.png')
writer.Write()
print('Look for trimesh_save.png in your current working directory.')
示例13: write_png
def write_png(self, filename=None):
large = vtk.vtkRenderLargeImage()
large.SetInput(self.ren)
large.SetMagnification(3)
png = vtk.vtkPNGWriter()
count = 0
if filename is None:
files = glob.glob('image*.png')
if len(files) > 0:
numbers = [int
(re.sub(r'image(\d+)\.png', r'\1', f))
for f in files]
count = max(numbers) + 1
filename = 'image{:0>4}.png'.format(count)
png.SetFileName(filename)
png.SetInputConnection(large.GetOutputPort())
png.Write()
示例14: SaveAsBMP
def SaveAsBMP(self,filename,resolution=1):
"""Saves the window as bmp-file.
Resolution is an integer representing the number of squares
that the window is divided into when writing to the bmp-file.
Thus choosing a higher number improves the quality of the
saved image.
"""
from vtk import vtkRenderLargeImage,vtkBMPWriter
#self.UpdateLight()
renderLarge = vtkRenderLargeImage()
renderLarge.SetInput(self.GetRenderer())
renderLarge.SetMagnification(resolution)
writer = vtkBMPWriter()
writer.SetFileName(filename)
writer.SetInput(renderLarge.GetOutput())
writer.Write()
示例15: take_screenshot
def take_screenshot(self,filename):
ren = self.GetRenderWindow().GetRenderers().GetFirstRenderer()
renderLarge = vtk.vtkRenderLargeImage()
if vtk_major_version <= 5:
renderLarge.SetInputData(ren)
else:
renderLarge.SetInput(ren)
renderLarge.SetMagnification(1)
# We write out the image which causes the rendering to occur. If you
# watch your screen you might see the pieces being rendered right
# after one another.
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(renderLarge.GetOutputPort())
# # # print "GOT HERE fileName=",fileName
writer.SetFileName(filename)
writer.Write()