本文整理汇总了Python中vtk.vtkJPEGWriter函数的典型用法代码示例。如果您正苦于以下问题:Python vtkJPEGWriter函数的具体用法?Python vtkJPEGWriter怎么用?Python vtkJPEGWriter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkJPEGWriter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: writeJPEG
def writeJPEG(self, fn):
filter = vtk.vtkWindowToImageFilter()
filter.SetInput(self.ren_win)
writer = vtk.vtkJPEGWriter()
writer.SetInput(filter.GetOutput())
writer.SetFileName(fn)
writer.Write()
开发者ID:argreiner,项目名称:sympler,代码行数:7,代码来源:sympler_viewer.py
示例2: save_jpeg
def save_jpeg(self, filename):
"""
Save the rendered screen as jpeg
"""
writer = vtk.vtkJPEGWriter()
writer.SetQuality(100)
self.saveScreen(writer, filename)
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:7,代码来源:VisualizerWindow.py
示例3: 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
示例4: writeAllImageSlices
def writeAllImageSlices(imgfn,pathfn,ext,output_dir):
reader = vtk.vtkMetaImageReader()
reader.SetFileName(imgfn)
reader.Update()
img = reader.GetOutput()
parsed_path = parsePathFile(pathfn)
slices = getAllImageSlices(img,parsed_path,ext)
writer = vtk.vtkJPEGWriter()
table = vtk.vtkLookupTable()
scalar_range = img.GetScalarRange()
table.SetRange(scalar_range[0], scalar_range[1]) # image intensity range
table.SetValueRange(0.0, 1.0) # from black to white
table.SetSaturationRange(0.0, 0.0) # no color saturation
table.SetRampToLinear()
table.Build()
# Map the image through the lookup table
color = vtk.vtkImageMapToColors()
color.SetLookupTable(table)
mkdir(output_dir)
for i in range(len(slices)):
color.SetInputData(slices[i])
writer.SetInputConnection(color.GetOutputPort())
writer.SetFileName(output_dir+'{}.jpg'.format(i))
writer.Update()
writer.Write()
开发者ID:gmaher,项目名称:tcl_code,代码行数:30,代码来源:utility.py
示例5: 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
示例6: save_rendered
def save_rendered(self, image_file_name):
"Output snapshot to image file"
image_file_type = os.path.splitext(image_file_name)[1]
# Remove existing image file
if os.path.exists(image_file_name):
if os.path.isfile(image_file_name):
os.remove(image_file_name)
else:
raise VisualizerError \
('Cannot overwrite image file: ' + image_file_name)
if image_file_type == '.bmp':
writer = vtk.vtkBMPWriter()
elif image_file_type == '.jpg':
writer = vtk.vtkJPEGWriter()
elif image_file_type == '.png':
writer = vtk.vtkPNGWriter()
elif image_file_type == '.tif':
writer = vtk.vtkTIFFWriter()
else:
error_info = 'Illegal image-file type: ' + image_file_type + '\n'
error_info += 'Please choose from "bmp","jpg","png","tif".'
raise VisualizerError(error_info)
w2i = vtk.vtkWindowToImageFilter()
w2i.SetInput(self.window)
self.window.Render()
writer.SetInput(w2i.GetOutput())
writer.SetFileName(image_file_name)
writer.Write()
开发者ID:ecell,项目名称:pd_visualizer,代码行数:33,代码来源:visualizer.py
示例7: OnExport
def OnExport(self, event):
"""Export to graphics filetype with extension ext."""
renWin = self.widget.GetRenderWindow()
wif = vtk.vtkWindowToImageFilter()
wif.SetInput(renWin)
wildcard = "PNG (*.png)|*.png|" \
"Postscript (*.ps)|*.ps|" \
"JPEG (*.jpg)|*.jpg"
# "TIFF (*.tif)|*.tif"
dialog = wx.FileDialog(None, "Export Graphics", os.getcwd(),
"", wildcard, wx.SAVE|wx.OVERWRITE_PROMPT)
if dialog.ShowModal() == wx.ID_OK:
path = dialog.GetPath()
base, ext = os.path.splitext(path)
if ext in ['.png', '.ps', '.jpg']:
pass
else:
i = dialog.GetFilterIndex()
ext = ['.png', '.ps', '.jpg'][i]
# cases
if ext == '.png':
psw = vtk.vtkPNGWriter()
elif ext == '.ps':
psw = vtk.vtkPostScriptWriter()
elif ext == '.jpg':
psw = vtk.vtkJPEGWriter()
psw.SetFileName(base + ext)
psw.SetInput(wif.GetOutput())
psw.Write()
开发者ID:cliburn,项目名称:flow,代码行数:30,代码来源:Main.py
示例8: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkJPEGWriter(), 'Writing vtkJPEG.',
('vtkJPEG',), (),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkJPEGWriter.py
示例9: renWriteJPEG
def renWriteJPEG(ren,args):
#@c Save the current window image to a file
#@c in jpeg format. If no filename is specified,
#@c then an interactive window is popped up asking
#@c for a name to be given.
#@a ren: renderer
#@a args: filename
if (args ==""):
filename = raw_input("Please enter image name to save")
else:
filename = args
if (filename ==""):
return
jwriter = vtk.vtkJPEGWriter()
jwriter.ProgressiveOff()
jwriter.SetQuality(95)
ren.GetRenderWindow().Render()
w2i = vtk.vtkWindowToImageFilter()
w2i.SetInput(ren.GetRenderWindow())
w2i.Update()
jwriter.SetInput(w2i.GetOutput())
jwriter.SetFileName(filename)
jwriter.Write()
del w2i
del jwriter
return
开发者ID:gmaher,项目名称:SimVascular,代码行数:31,代码来源:renfun.py
示例10: capture_image
def capture_image(self,obj,eve):
self.renWin.Render()
self.w2i = vtk.vtkWindowToImageFilter()
self.w2i.SetInput(self.renWin)
self.writer = vtk.vtkJPEGWriter()
self.writer.SetInputConnection(self.w2i.GetOutputPort())
self.writer.SetFileName(`self.print_counter` + "vectorscreen.jpg");
self.print_counter =1 + self.print_counter
self.writer.Write()
开发者ID:svelezsaffon,项目名称:vector_field_visualization_vtk,代码行数:9,代码来源:streamlines.py
示例11: saveToImage
def saveToImage(self,window,fileName):
fileName = "{}.jpeg".format(fileName);
w2if = vtk.vtkWindowToImageFilter()
w2if.SetInput(window)
w2if.Update()
writer = vtk.vtkJPEGWriter()
writer.SetFileName(fileName);
writer.SetInputConnection(w2if.GetOutputPort())
writer.Write()
self.seq.append(fileName);
开发者ID:avontd2868,项目名称:OU_Final_Year,代码行数:10,代码来源:vtkOperations.py
示例12: plotToFile
def plotToFile(fName, renWin, renderer, width, height,fileFormat):
w2i = vtk.vtkWindowToImageFilter()
writer = vtk.vtkJPEGWriter()
w2i.SetInput(renWin)
w2i.Update()
writer.SetInputConnection(w2i.GetOutputPort())
writer.SetFileName(fName)
renWin.Render()
w2i.Update()
writer.Write()
开发者ID:lcpt,项目名称:xc_utils,代码行数:10,代码来源:displayVtk.py
示例13: snapshot
def snapshot(self):
fn = FD.asksaveasfilename(title="Save snapshot",filetypes=[("JPEG format", "*.jpg "),("TIFF format", "*.tif "),("PNG format", "*.png ")])
if fn == '':
return
w2i = vtk.vtkWindowToImageFilter()
w2i.SetInput(self.renwin)
w2i.Update()
if fn.endswith('tif') or fn.endswith('TIF') :
writer = vtk.vtkTIFFWriter()
elif fn.endswith('jpg') or fn.endswith('JPG') or fn.endswith('jpeg') or fn.endswith('JPEG'):
writer = vtk.vtkJPEGWriter()
elif fn.endswith('png') or fn.endswith('PNG'):
writer = vtk.vtkPNGWriter()
else:
fn += '.jpg'
writer = vtk.vtkJPEGWriter()
writer.SetFileName(fn)
writer.SetInputConnection(w2i.GetOutputPort())
self.renwin.Render()
writer.Write()
开发者ID:ggoret,项目名称:VEDA,代码行数:20,代码来源:gfx.py
示例14: plot
def plot(self,fName):
'''Plots window contents'''
w2i = vtk.vtkWindowToImageFilter()
writer = vtk.vtkJPEGWriter()
w2i.SetInput(self.renWin)
w2i.Update()
writer.SetInputConnection(w2i.GetOutputPort())
writer.SetFileName(fName)
self.renWin.Render()
w2i.Update()
writer.Write()
开发者ID:lcpt,项目名称:xc,代码行数:11,代码来源:vtk_graphic_base.py
示例15: 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
示例16: ImageWriter
def ImageWriter(renderer, camera=None, outCompressionType="jpg", suppress=False, dimension=[400, 400], AAFrames=5):
"""
Write image from renderer to a figure.
:param renderer: vtkRenderer
:param dimension (Optional)Dimension of output, e.g. [x, y]
:param camera: (Optional)vtkCameraObject
:param outCompressionType: (Optional)Specify output format, support "png", "jpeg", default to "png"
:param outFileName: (Optional)Filename of the output
:param supress: (Optional)Suppress output file
:return:
Note:
Depending on the version of vtk and graphics driver,
the vtkRenderWindow.SetOffScreenRendering(1) may behave strangely, it is therefore advised
to use the xvfbwrapper if you are hosting a headless server and comment the line that writes
renderWin.SetOffScreenRendering(1) in this function.
Alternatively, if you managed to compile VTK from souce with the option VTK_USE_OFFSCREEN
on then you might simply use SetOffScreenRendering(1)/OffScreenRenderingOn() and suppress
xvfbwrapper through the code by setting config.vdisplay=False
"""
renderWin = vtk.vtkRenderWindow()
renderWin.AddRenderer(renderer)
renderWin.OffScreenRenderingOn()
renderWin.SetSize(int(dimension[0]), int(dimension[1]))
renderWin.Render() # TODO: Error for nifti here
renderWin.SetAAFrames(AAFrames)
# ** Note that rendering does not work with the interactor. **
windowToImageFilter = vtk.vtkWindowToImageFilter()
windowToImageFilter.SetInput(renderWin)
windowToImageFilter.Update()
if camera != None:
renderer.SetActiveCamera(camera)
# Writer the render to image
if outCompressionType == "png":
writer = vtk.vtkPNGWriter()
if outCompressionType == "jpeg" or outCompressionType == "jpg":
writer = vtk.vtkJPEGWriter()
writer.SetWriteToMemory(1)
writer.SetInputConnection(windowToImageFilter.GetOutputPort())
if suppress == False:
writer.Write()
result = writer.GetResult()
return result
开发者ID:teracamo,项目名称:CloudVisualizeServer,代码行数:52,代码来源:VolumeRendering.py
示例17: save_jpg
def save_jpg(self, file_name="", quality=None, progressive=None):
"""Requires VTK 4 to work. Arguments: file_name if passed
will be used, quality is the quality of the JPEG (10-100) are
valid, the progressive arguments toggles progressive jpegs."""
debug ("In RenderWindow::save_jpg ()")
try:
ex = vtk.vtkJPEGWriter()
except AttributeError:
msg = "Saving to a JPEG file is not supported by your "\
"version of VTK. Versions 4.0 and above support this."
Common.print_err (msg)
return
if not file_name:
file_name = tk_fsave (title="Export to JPEG image",
initialdir=Common.config.initial_dir,
defaultextension=".jpg",
filetypes=[("JPEG images", "*.jpg"),
("JPEG images", "*.jpeg"),
("All files", "*")])
if len (file_name) != 0:
if not quality and not progressive:
d = JPEGDialog (self.frame, [75, 1])
if d.result:
quality, progressive = d.result
else:
return
Common.state.busy ()
w2if = vtk.vtkWindowToImageFilter ()
w2if.SetMagnification (Common.config.magnification)
self.lift ()
w2if.SetInput (self.renwin)
ex = vtk.vtkJPEGWriter ()
ex.SetQuality (quality)
ex.SetProgressive (progressive)
ex.SetFileName (file_name)
ex.SetInput (w2if.GetOutput ())
ex.Write ()
Common.state.idle ()
开发者ID:sldion,项目名称:DNACC,代码行数:38,代码来源:RenderWindow.py
示例18: saveGif
def saveGif(window, n):
path = sys.argv[0]
if os.path.isfile(path):
path = os.path.dirname(path)
path += '/Data/Gif/img%d.jpg' % n
window_image_filter = vtk.vtkWindowToImageFilter()
writer = vtk.vtkJPEGWriter()
window_image_filter.SetInput(window)
window_image_filter.Update()
writer.SetInputConnection(window_image_filter.GetOutputPort())
writer.SetFileName(path)
writer.Write()
开发者ID:guohengkai,项目名称:MIRVAP,代码行数:14,代码来源:SurfaceGifView.py
示例19: save_image
def save_image(self, filename="test.jpg"):
img = vtk.vtkWindowToImageFilter()
img.SetInput(self.render_window)
img.SetMagnification(self.magnification)
img.Update()
#writer = vtk.vtkPNGWriter()
writer = vtk.vtkJPEGWriter()
if (vtk.vtkVersion().GetVTKMajorVersion() >= 6.0):
writer.SetInputConnection(img.GetOutputPort())
else:
writer.SetInput(img.GetOutput())
writer.SetFileName(filename)
writer.Write()
del writer
del img
开发者ID:zhangfanmark,项目名称:whitematteranalysis,代码行数:16,代码来源:render.py
示例20: _handleFailedImage
def _handleFailedImage(idiff, pngr, img_fname):
"""Writes all the necessary images when an image comparison
failed."""
f_base, f_ext = os.path.splitext(img_fname)
# write out the difference file in full.
pngw = vtk.vtkPNGWriter()
pngw.SetFileName(_getTempImagePath(f_base + ".diff.png"))
pngw.SetInput(idiff.GetOutput())
pngw.Write()
# write the difference image scaled and gamma adjusted for the
# dashboard.
sz = pngr.GetOutput().GetDimensions()
if sz[1] <= 250.0:
mag = 1.0
else:
mag = 250.0/sz[1]
shrink = vtk.vtkImageResample()
shrink.SetInput(idiff.GetOutput())
shrink.InterpolateOn()
shrink.SetAxisMagnificationFactor(0, mag)
shrink.SetAxisMagnificationFactor(1, mag)
gamma = vtk.vtkImageShiftScale()
gamma.SetInput(shrink.GetOutput())
gamma.SetShift(0)
gamma.SetScale(10)
jpegw = vtk.vtkJPEGWriter()
jpegw.SetFileName(_getTempImagePath(f_base + ".diff.small.jpg"))
jpegw.SetInput(gamma.GetOutput())
jpegw.SetQuality(85)
jpegw.Write()
# write out the image that was generated.
shrink.SetInput(idiff.GetInput())
jpegw.SetInput(shrink.GetOutput())
jpegw.SetFileName(_getTempImagePath(f_base + ".test.small.jpg"))
jpegw.Write()
# write out the valid image that matched.
shrink.SetInput(idiff.GetImage())
jpegw.SetInput(shrink.GetOutput())
jpegw.SetFileName(_getTempImagePath(f_base + ".small.jpg"))
jpegw.Write()
开发者ID:SRabbelier,项目名称:Casam,代码行数:47,代码来源:Testing.py
注:本文中的vtk.vtkJPEGWriter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论