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


Python matplotlib.image方法代码示例

本文整理汇总了Python中matplotlib.image方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.image方法的具体用法?Python matplotlib.image怎么用?Python matplotlib.image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.image方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: switch_backend

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def switch_backend(newbackend):
    """
    Switch the default backend.  This feature is **experimental**, and
    is only expected to work switching to an image backend.  e.g., if
    you have a bunch of PostScript scripts that you want to run from
    an interactive ipython session, you may want to switch to the PS
    backend before running them to avoid having a bunch of GUI windows
    popup.  If you try to interactively switch from one GUI backend to
    another, you will explode.

    Calling this command will close all open windows.
    """
    close('all')
    global _backend_mod, new_figure_manager, draw_if_interactive, _show
    matplotlib.use(newbackend, warn=False, force=True)
    from matplotlib.backends import pylab_setup
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:pyplot.py

示例2: clim

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def clim(vmin=None, vmax=None):
    """
    Set the color limits of the current image.

    To apply clim to all axes images do::

      clim(0, 0.5)

    If either *vmin* or *vmax* is None, the image min/max respectively
    will be used for color scaling.

    If you want to set the clim of multiple images,
    use, for example::

      for im in gca().get_images():
          im.set_clim(0, 0.05)

    """
    im = gci()
    if im is None:
        raise RuntimeError('You must first define an image, eg with imshow')

    im.set_clim(vmin, vmax)
    draw_if_interactive() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:pyplot.py

示例3: set_cmap

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def set_cmap(cmap):
    """
    Set the default colormap.  Applies to the current image if any.
    See help(colormaps) for more information.

    *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or
    the name of a registered colormap.

    See :func:`matplotlib.cm.register_cmap` and
    :func:`matplotlib.cm.get_cmap`.
    """
    cmap = cm.get_cmap(cmap)

    rc('image', cmap=cmap.name)
    im = gci()

    if im is not None:
        im.set_cmap(cmap)

    draw_if_interactive() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:pyplot.py

示例4: get_plot_formats

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def get_plot_formats(config):
    default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 200}
    formats = []
    plot_formats = config.plot_formats
    if isinstance(plot_formats, six.string_types):
        # String Sphinx < 1.3, Split on , to mimic
        # Sphinx 1.3 and later. Sphinx 1.3 always
        # returns a list.
        plot_formats = plot_formats.split(',')
    for fmt in plot_formats:
        if isinstance(fmt, six.string_types):
            if ':' in fmt:
                suffix, dpi = fmt.split(':')
                formats.append((str(suffix), int(dpi)))
            else:
                formats.append((fmt, default_dpi.get(fmt, 80)))
        elif type(fmt) in (tuple, list) and len(fmt) == 2:
            formats.append((str(fmt[0]), int(fmt[1])))
        else:
            raise PlotError('invalid image format "%r" in plot_formats' % fmt)
    return formats 
开发者ID:statlab,项目名称:permute,代码行数:23,代码来源:plot_directive.py

示例5: get_plot_formats

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def get_plot_formats(config):
    default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 200}
    formats = []
    plot_formats = config.plot_formats
    for fmt in plot_formats:
        if isinstance(fmt, str):
            if ':' in fmt:
                suffix, dpi = fmt.split(':')
                formats.append((str(suffix), int(dpi)))
            else:
                formats.append((fmt, default_dpi.get(fmt, 80)))
        elif isinstance(fmt, (tuple, list)) and len(fmt) == 2:
            formats.append((str(fmt[0]), int(fmt[1])))
        else:
            raise PlotError('invalid image format "%r" in plot_formats' % fmt)
    return formats 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:18,代码来源:plot_directive.py

示例6: clim

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def clim(vmin=None, vmax=None):
    """
    Set the color limits of the current image.

    To apply clim to all axes images do::

      clim(0, 0.5)

    If either *vmin* or *vmax* is None, the image min/max respectively
    will be used for color scaling.

    If you want to set the clim of multiple images,
    use, for example::

      for im in gca().get_images():
          im.set_clim(0, 0.05)

    """
    im = gci()
    if im is None:
        raise RuntimeError('You must first define an image, e.g., with imshow')

    im.set_clim(vmin, vmax)
    draw_if_interactive() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:26,代码来源:pyplot.py

示例7: gci

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def gci():
    """
    Get the current colorable artist.  Specifically, returns the
    current :class:`~matplotlib.cm.ScalarMappable` instance (image or
    patch collection), or *None* if no images or patch collections
    have been defined.  The commands :func:`~matplotlib.pyplot.imshow`
    and :func:`~matplotlib.pyplot.figimage` create
    :class:`~matplotlib.image.Image` instances, and the commands
    :func:`~matplotlib.pyplot.pcolor` and
    :func:`~matplotlib.pyplot.scatter` create
    :class:`~matplotlib.collections.Collection` instances.  The
    current image is an attribute of the current axes, or the nearest
    earlier axes in the current figure that contains an image.
    """
    return gcf()._gci()


## Any Artist ##


# (getp is simply imported) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:23,代码来源:pyplot.py

示例8: clim

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def clim(vmin=None, vmax=None):
    """
    Set the color limits of the current image.

    To apply clim to all axes images do::

      clim(0, 0.5)

    If either *vmin* or *vmax* is None, the image min/max respectively
    will be used for color scaling.

    If you want to set the clim of multiple images,
    use, for example::

      for im in gca().get_images():
          im.set_clim(0, 0.05)

    """
    im = gci()
    if im is None:
        raise RuntimeError('You must first define an image, e.g., with imshow')

    im.set_clim(vmin, vmax) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:25,代码来源:pyplot.py

示例9: test

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def test(train_loader, model, model2, dir):
    totalNumber = 0
    errorSum = {'MSE': 0, 'RMSE': 0, 'ABS_REL': 0, 'LG10': 0,
                'MAE': 0,  'DELTA1': 0, 'DELTA2': 0, 'DELTA3': 0}
    model.eval()
    model2.eval()

    # if not os.path.exists(dir):
    #     os.mkdir(dir)

    for i, sample_batched in enumerate(train_loader):
        image, depth_ = sample_batched['image'], sample_batched['depth']

        image = torch.autograd.Variable(image, volatile=True).cuda()
        depth_ = torch.autograd.Variable(depth_, volatile=True).cuda(async=True)
 
        depth = model(image)

        mask = model2(image)
        output = model(image*mask)

        batchSize = depth.size(0)
        errors = util.evaluateError(output,depth_)
        errorSum = util.addErrors(errorSum, errors, batchSize)
        totalNumber = totalNumber + batchSize
        averageError = util.averageErrors(errorSum, totalNumber)

        # mask = mask.squeeze().view(228,304).data.cpu().float().numpy()
        # matplotlib.image.imsave(dir+'/mask'+str(i)+'.png', mask)
 
    print('rmse:',np.sqrt(averageError['MSE'])) 
开发者ID:JunjH,项目名称:Visualizing-CNNs-for-monocular-depth-estimation,代码行数:33,代码来源:test.py

示例10: region

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def region(self, region):
        "Extract a subset of the SARData image defined by a Region object"
        s = SARData()
        s.hhhh = self.hhhh.reshape(self.shape)[np.ix_(region.range_i, region.range_j)].flatten()
        s.hhhv = self.hhhv.reshape(self.shape)[np.ix_(region.range_i, region.range_j)].flatten()
        s.hvhv = self.hvhv.reshape(self.shape)[np.ix_(region.range_i, region.range_j)].flatten()
        s.hhvv = self.hhvv.reshape(self.shape)[np.ix_(region.range_i, region.range_j)].flatten()
        s.hvvv = self.hvvv.reshape(self.shape)[np.ix_(region.range_i, region.range_j)].flatten()
        s.vvvv = self.vvvv.reshape(self.shape)[np.ix_(region.range_i, region.range_j)].flatten()
        s.shape = (len(region.range_i), len(region.range_j))
        s.size = len(region.range_i) * len(region.range_j)
        return s 
开发者ID:fouronnes,项目名称:SAR-change-detection,代码行数:14,代码来源:sar_data.py

示例11: masked_region

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def masked_region(self, mask):
        "Extract a subset of the SARData image defined by a mask"
        assert(mask.shape == self.hhhh.shape)

        s = SARData()
        for c in ["hhhh", "hhhv", "hvhv", "hhvv", "hvvv", "vvvv"]:
            s.__dict__[c] = self.__dict__[c][mask]
        s.shape = None
        s.size = mask.sum()
        return s 
开发者ID:fouronnes,项目名称:SAR-change-detection,代码行数:12,代码来源:sar_data.py

示例12: color_composite

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def color_composite(self):
        "Color composite of a EMISAR image"

        # Take logarithm
        green = 10*np.log(self.hhhh.reshape(self.shape)) / np.log(10)
        blue = 10*np.log(self.vvvv.reshape(self.shape)) / np.log(10)
        red = 10*np.log(self.hvhv.reshape(self.shape)) / np.log(10)

        # Normalize
        green = matplotlib.colors.normalize(-30, 0, clip=True)(green)
        blue = matplotlib.colors.normalize(-30, 0, clip=True)(blue)
        red = matplotlib.colors.normalize(-36, -6, clip=True)(red)

        # Return as a RGB image
        return np.concatenate((red[:,:,None], green[:,:,None], blue[:,:,None]), axis=2) 
开发者ID:fouronnes,项目名称:SAR-change-detection,代码行数:17,代码来源:sar_data.py

示例13: rcdefaults

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def rcdefaults():
    matplotlib.rcdefaults()
    draw_if_interactive()


# The current "image" (ScalarMappable) is retrieved or set
# only via the pyplot interface using the following two
# functions: 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:pyplot.py

示例14: gci

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def gci():
    """
    Get the current colorable artist.  Specifically, returns the
    current :class:`~matplotlib.cm.ScalarMappable` instance (image or
    patch collection), or *None* if no images or patch collections
    have been defined.  The commands :func:`~matplotlib.pyplot.imshow`
    and :func:`~matplotlib.pyplot.figimage` create
    :class:`~matplotlib.image.Image` instances, and the commands
    :func:`~matplotlib.pyplot.pcolor` and
    :func:`~matplotlib.pyplot.scatter` create
    :class:`~matplotlib.collections.Collection` instances.  The
    current image is an attribute of the current axes, or the nearest
    earlier axes in the current figure that contains an image.
    """
    return gcf()._gci() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:pyplot.py

示例15: sci

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import image [as 别名]
def sci(im):
    """
    Set the current image.  This image will be the target of colormap
    commands like :func:`~matplotlib.pyplot.jet`,
    :func:`~matplotlib.pyplot.hot` or
    :func:`~matplotlib.pyplot.clim`).  The current image is an
    attribute of the current axes.
    """
    gca()._sci(im)


## Any Artist ##
# (getp is simply imported) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:pyplot.py


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