當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。