当前位置: 首页>>代码示例>>Python>>正文


Python _image.NEAREST属性代码示例

本文整理汇总了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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:image.py

示例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 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:58,代码来源:image.py


注:本文中的matplotlib._image.NEAREST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。