本文整理汇总了Python中matplotlib._image.fromarray函数的典型用法代码示例。如果您正苦于以下问题:Python fromarray函数的具体用法?Python fromarray怎么用?Python fromarray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fromarray函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: make_image
def make_image(self, magnification=1.0):
if self._A is None:
raise RuntimeError('You must first set the image array')
x = self.to_rgba(self._A, self._alpha)
self.magnification = magnification
# if magnification is not one, we need to resize
ismag = magnification!=1
#if ismag: raise RuntimeError
if ismag:
isoutput = 0
else:
isoutput = 1
im = _image.fromarray(x, isoutput)
fc = self.figure.get_facecolor()
im.set_bg( *mcolors.colorConverter.to_rgba(fc, 0) )
im.is_grayscale = (self.cmap.name == "gray" and
len(self._A.shape) == 2)
if ismag:
numrows, numcols = self.get_size()
numrows *= magnification
numcols *= magnification
im.set_interpolation(_image.NEAREST)
im.resize(numcols, numrows)
if self.origin=='upper':
im.flipud_out()
return im
开发者ID:zoccolan,项目名称:eyetracker,代码行数:29,代码来源:image.py
示例2: stop_filter
def stop_filter(self, post_processing):
return RendererBase.stop_filter(self, post_processing)
"""
Save the plot in the current canvas as a image and apply
the *post_processing* function.
def post_processing(image, dpi):
# ny, nx, depth = image.shape
# image (numpy array) has RGBA channels and has a depth of 4.
...
# create a new_image (numpy array of 4 channels, size can be
# different). The resulting image may have offsets from
# lower-left corner of the original image
return new_image, offset_x, offset_y
The saved renderer is restored and the returned image from
post_processing is plotted (using draw_image) on it.
"""
# WARNING.
# For agg_filter to work, the rendere's method need
# to overridden in the class. See draw_markers, and draw_path_collections
from matplotlib._image import fromarray
width, height = int(self.width), int(self.height)
buffer, bounds = self._renderer.tostring_rgba_minimized()
l, b, w, h = bounds
self._renderer = self._filter_renderers.pop()
self._update_methods()
if w > 0 and h > 0:
img = np.fromstring(buffer, np.uint8)
img, ox, oy = post_processing(img.reshape((h, w, 4)) / 255.,
self.dpi)
image = fromarray(np.flipud(img), 1)
# image.flipud_out()
gc = self.new_gc()
self._renderer.draw_image(gc,
l+ox, height - b - h +oy,
image)
开发者ID:piScope,项目名称:piScope,代码行数:46,代码来源:renderer_gl.py
示例3: draw_tex
def draw_tex(self, gc, x, y, s, prop, angle):
# todo, handle props, angle, origins
rgb = gc.get_rgb()
size = prop.get_size_in_points()
dpi = self.dpi.get()
flip = angle==90
w,h,d = self.get_text_width_height_descent(s, prop, 'TeX', rgb)
if flip:
w,h = h,w
x -= w
texmanager = self.get_texmanager()
key = s, size, dpi, rgb, angle, texmanager.get_font_config()
im = self.texd.get(key)
if im is None:
Z = texmanager.get_rgba(s, size, dpi, rgb)
if flip:
r = Z[:,:,0]
g = Z[:,:,1]
b = Z[:,:,2]
a = Z[:,:,3]
m,n,tmp = Z.shape
def func(x):
return npy.transpose(npy.fliplr(x))
Z = npy.zeros((n,m,4), float)
Z[:,:,0] = func(r)
Z[:,:,1] = func(g)
Z[:,:,2] = func(b)
Z[:,:,3] = func(a)
im = fromarray(Z, 1)
im.flipud_out()
self.texd[key] = im
cliprect = gc.get_clip_rectangle()
if cliprect is None: bbox = None
else: bbox = lbwh_to_bbox(*cliprect)
self.draw_image(x, self.height-y, im, bbox)
开发者ID:gkliska,项目名称:razvoj,代码行数:40,代码来源:backend_agg.py
注:本文中的matplotlib._image.fromarray函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论