本文整理汇总了Python中matplotlib._image.NEAREST属性的典型用法代码示例。如果您正苦于以下问题:Python _image.NEAREST属性的具体用法?Python _image.NEAREST怎么用?Python _image.NEAREST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类matplotlib._image
的用法示例。
在下文中一共展示了_image.NEAREST属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_image
# 需要导入模块: from matplotlib import _image [as 别名]
# 或者: from matplotlib._image import NEAREST [as 别名]
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, bytes=True)
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.frombyte(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
示例2: composite_images
# 需要导入模块: from matplotlib import _image [as 别名]
# 或者: from matplotlib._image import NEAREST [as 别名]
def composite_images(images, renderer, magnification=1.0):
"""
Composite a number of RGBA images into one. The images are
composited in the order in which they appear in the `images` list.
Parameters
----------
images : list of Images
Each must have a `make_image` method. For each image,
`can_composite` should return `True`, though this is not
enforced by this function. Each image must have a purely
affine transformation with no shear.
renderer : RendererBase instance
magnification : float
The additional magnification to apply for the renderer in use.
Returns
-------
tuple : image, offset_x, offset_y
Returns the tuple:
- image: A numpy array of the same type as the input images.
- offset_x, offset_y: The offset of the image (left, bottom)
in the output figure.
"""
if len(images) == 0:
return np.empty((0, 0, 4), dtype=np.uint8), 0, 0
parts = []
bboxes = []
for image in images:
data, x, y, trans = image.make_image(renderer, magnification)
if data is not None:
x *= magnification
y *= magnification
parts.append((data, x, y, image.get_alpha() or 1.0))
bboxes.append(
Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]]))
if len(parts) == 0:
return np.empty((0, 0, 4), dtype=np.uint8), 0, 0
bbox = Bbox.union(bboxes)
output = np.zeros(
(int(bbox.height), int(bbox.width), 4), dtype=np.uint8)
for data, x, y, alpha in parts:
trans = Affine2D().translate(x - bbox.x0, y - bbox.y0)
_image.resample(data, output, trans, _image.NEAREST,
resample=False, alpha=alpha)
return output, bbox.x0 / magnification, bbox.y0 / magnification