本文整理汇总了Python中vtk.vtkRenderLargeImage函数的典型用法代码示例。如果您正苦于以下问题:Python vtkRenderLargeImage函数的具体用法?Python vtkRenderLargeImage怎么用?Python vtkRenderLargeImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkRenderLargeImage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkRenderLargeImage(), 'Processing.',
(), ('vtkImageData',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkRenderLargeImage.py
示例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
开发者ID:odellus,项目名称:CompuCell3D,代码行数:26,代码来源:MVCDrawView2D.py
示例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
开发者ID:akashneo,项目名称:pymatgen,代码行数:28,代码来源:structure_vtk.py
示例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()
开发者ID:sukhbinder,项目名称:cyNastran,代码行数:25,代码来源:actionsControl.py
示例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!"
开发者ID:dxli,项目名称:openvoronoi,代码行数:9,代码来源:poisson_stat_1.py
示例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')
开发者ID:Houssk,项目名称:invesalius3,代码行数:53,代码来源:viewer_slice.py
示例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.')
开发者ID:yarikoptic,项目名称:dipy,代码行数:14,代码来源:fvtk.py
示例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()
开发者ID:dlrdave,项目名称:VTKWikiExamples,代码行数:14,代码来源:CurvatureBandsWithGlyphs.py
示例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()
开发者ID:AngeloTorelli,项目名称:CompuCell3D,代码行数:14,代码来源:MVCDrawView3D.py
示例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()
开发者ID:apayne9,项目名称:PyChemia,代码行数:15,代码来源:teste.py
示例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()
开发者ID:baishi,项目名称:3dbar,代码行数:16,代码来源:barreconstructor.py
示例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.')
开发者ID:StongeEtienne,项目名称:trimeshpy,代码行数:16,代码来源:trimesh_vtk.py
示例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()
开发者ID:siudej,项目名称:Steklov-eigenvalues,代码行数:17,代码来源:viper3d.py
示例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()
开发者ID:danse-inelastic,项目名称:inelastic-svn,代码行数:19,代码来源:RenderWidget.py
示例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()
开发者ID:maciekswat,项目名称:ram_plots,代码行数:20,代码来源:brain_plots_mac_colors_clip.py
示例16: onTakePicture
def onTakePicture(self, event):
renderLarge = vtk.vtkRenderLargeImage()
renderLarge.SetInput(self.getRenderer())
renderLarge.SetMagnification(4)
wildcard = "PNG (*.png)|*.png|" \
"JPEG (*.jpeg; *.jpeg; *.jpg; *.jfif)|*.jpg;*.jpeg;*.jpg;*.jfif|" \
"TIFF (*.tif; *.tiff)|*.tif;*.tiff|" \
"BMP (*.bmp)|*.bmp|" \
"PostScript (*.ps)|*.ps|" \
"All files (*.*)|*.*"
dlg = wx.FileDialog(None, "Choose a file", self.dirname,
"", wildcard, wx.SAVE | wx.OVERWRITE_PROMPT)
if dlg.ShowModal() == wx.ID_OK:
fname = dlg.GetFilename()
self.dirname = dlg.GetDirectory()
fname = os.path.join(self.dirname, fname)
print "fname = ", fname
# 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.
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.SetInputConnection(renderLarge.GetOutputPort())
writer.SetFileName(fname)
writer.Write()
dlg.Destroy()
开发者ID:xirxa,项目名称:pynastran-locr,代码行数:40,代码来源:actionsControl.py
示例17: photo
def photo(self):
print "photo"
magnif=str(self.plainTextEdit_2.toPlainText ())
if magnif=="":
magnif=1
else:
magnif=int(magnif)
w2if=vtk.vtkWindowToImageFilter()
w2if.Update()
renderLarge= vtk.vtkRenderLargeImage()
renderer=self.qvtkWidget.GetRenderWindow().GetRenderers().GetFirstRenderer()
renderLarge.SetInput(renderer)
renderLarge.SetMagnification(magnif)
writer=vtk.vtkPNGWriter()
writer.SetInputConnection(renderLarge.GetOutputPort())
writer.SetFileName(str(QtGui.QFileDialog.getOpenFileName(directory ="./output")))
writer.Write()
开发者ID:bitcoinsoftware,项目名称:3D-Scientific-Visualization,代码行数:22,代码来源:camera_buttons_functions.py
示例18: OnExportPicture
def OnExportPicture(self, pubsub_evt):
Publisher.sendMessage('Begin busy cursor')
id, filename, filetype = pubsub_evt.data
if id == const.VOLUME:
if filetype == const.FILETYPE_POV:
renwin = self.interactor.GetRenderWindow()
image = vtk.vtkWindowToImageFilter()
image.SetInput(renwin)
writer = vtk.vtkPOVExporter()
writer.SetFileName(filename)
writer.SetRenderWindow(renwin)
writer.Write()
else:
#Use tiling to generate a large rendering.
image = vtk.vtkRenderLargeImage()
image.SetInput(self.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()
Publisher.sendMessage('End busy cursor')
开发者ID:151706061,项目名称:invesalius3,代码行数:38,代码来源:viewer_volume.py
示例19: record
def record(ren, outdir, prefix, cam_pos=None, cam_focal=None,
cam_view=None, n_frames=1, az_ang=10, size=(300, 300),
animate=False, delay=100, verbose=False):
""" This will record a snap/video of the rendered objects.
Records a video as a series of ".png" files by rotating the azimuth angle
'az_ang' in every frame.
Parameters
----------
ren: vtkRenderer() object (mandatory)
as returned from function ren()
outdir: str (mandatory)
the output directory.
prefix: str (mandatory)
the png snap base names.
cam_pos: 3-uplet (optional, default None)
the camera position.
cam_focal: 3-uplet (optional, default None)
the camera focal point.
cam_view: 3-uplet (optional, default None)
the camera view up.
n_frames: int (optional, default 1)
the number of frames to save.
az_ang: float (optional, default 10)
the azimuthal angle of camera rotation (in degrees).
size: 2-uplet (optional, default (300, 300))
(width, height) of the window.
animate: bool (optional, default False)
if True agglomerate the generated snaps in a Gif and delete the
raw snaps.
delay: int (optional, default 100)
this option is useful for regulating the animation of image
sequences ticks/ticks-per-second seconds must expire before the
display of the next image. The default is no delay between each
showing of the image sequence. The default ticks-per-second is 100.
verbose: bool (optional, default False)
if True display debuging message.
Returns
-------
snaps: list of str
the generated snaps.
"""
# Create a window and a interactor
window = vtk.vtkRenderWindow()
window.AddRenderer(ren)
window.SetSize(size)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(window)
# Set the camera properties
ren.ResetCamera()
camera = ren.GetActiveCamera()
if cam_pos is not None:
camera.SetPosition(cam_pos)
if cam_focal is not None:
camera.SetFocalPoint(cam_focal)
if cam_view is not None:
camera.SetViewUp(cam_view)
if verbose:
print("Camera Position (%.2f,%.2f,%.2f)" % camera.GetPosition())
print("Camera Focal Point (%.2f,%.2f,%.2f)" % camera.GetFocalPoint())
print("Camera View Up (%.2f,%.2f,%.2f)" % camera.GetViewUp())
# Create 'n_frames' by rotating each time the scene by 'az_ang' degrees
writer = vtk.vtkPNGWriter()
snaps = []
for index in range(n_frames):
render = vtk.vtkRenderLargeImage()
render.SetInput(ren)
render.SetMagnification(1)
render.Update()
writer.SetInputConnection(render.GetOutputPort())
current_prefix = prefix
if n_frames > 1:
current_prefix += "-" + str(index + 1).zfill(8)
snap_file = os.path.join(outdir, current_prefix + ".png")
writer.SetFileName(snap_file)
snaps.append(snap_file)
writer.Write()
camera.Azimuth(az_ang)
# Create an animation
if animate:
giffile = os.path.join(outdir, prefix + ".gif")
images_to_gif(snaps, giffile, delay=delay)
for fname in snaps:
os.remove(fname)
snaps = [giffile]
return snaps
开发者ID:gareaut,项目名称:caps-clindmri,代码行数:92,代码来源:pvtk.py
示例20: record
def record(ren=None,cam_pos=None,cam_focal=None,cam_view=None,outdir=None,n_frames=10, az_ang=10, magnification=1,size=(125,125),bgr_color=(0.1,0.2,0.4)):
''' This will record a video of your scene
Records a video as a series of .png files of your scene by rotating the azimuth angle az_angle in every frame
Parameters
-----------
ren : vtkRenderer() object
as returned from function ren()
cam_pos : None or sequence (3,)
camera position
cam_focal : None or sequence (3,)
camera focal point
cam_view : None or sequence (3,)
camera view up
outdir : str
output directory for the frames
n_frames : int
number of frames to save
az_ang : float
azimuthal angle of camera rotation
magnification : int
how much to magnify the saved frame
Examples
---------
>>> from dipy.viz import fvtk
>>> r=fvtk.ren()
>>> a=fvtk.axes()
>>> from dipy.viz import fvtk
>>> r=fvtk.ren()
>>> fvtk.add(r,fvtk.axes())
>>> #uncomment below to record
>>> #fvtk.record(r,cam_pos=(0,0,-10))
'''
if ren==None:
ren = vtk.vtkRenderer()
ren.SetBackground(bgr_color)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(size[0],size[1])
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
#ren.GetActiveCamera().Azimuth(180)
'''
# We'll set up the view we want.
ren.GetActiveCamera().SetPosition(0, 1, 0)
ren.GetActiveCamera().SetFocalPoint(0, 0, 0)
ren.GetActiveCamera().SetViewUp(0, 0, 1)
# Let the renderer compute a good position and focal point.
ren.ResetCamera()
ren.GetActiveCamera().Dolly(1.4)
ren.ResetCameraClippingRange()
'''
renderLarge = vtk.vtkRenderLargeImage()
renderLarge.SetInput(ren)
renderLarge.SetMagnification(magnification)
renderLarge.Update()
writer = vtk.vtkPNGWriter()
ang=0
if cam_pos!=None:
cx,cy,cz=cam_pos
ren.GetActiveCamera().SetPosition(cx,cy,cz)
if cam_focal!=None:
fx,fy,fz=cam_focal
ren.GetActiveCamera().SetFocalPoint(fx,fy,fz)
if cam_view!=None:
ux,uy,uz=cam_view
ren.GetActiveCamera().SetViewUp(ux, uy, uz)
for i in range(n_frames):
ren.GetActiveCamera().Azimuth(ang)
renderLarge = vtk.vtkRenderLargeImage()
renderLarge.SetInput(ren)
renderLarge.SetMagnification(magnification)
renderLarge.Update()
writer.SetInputConnection(renderLarge.GetOutputPort())
#filename='/tmp/'+str(3000000+i)+'.png'
if outdir==None:
filename=str(1000000+i)+'.png'
else:
filename=outdir+str(1000000+i)+'.png'
writer.SetFileName(filename)
writer.Write()
ang=+az_ang
开发者ID:yarikoptic,项目名称:dipy,代码行数:95,代码来源:fvtk.py
注:本文中的vtk.vtkRenderLargeImage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论