python100例,python 讀入圖像文件和輸出圖像文件

 2023-10-21 阅读 27 评论 0

摘要:目錄 Matplotlib Python讀入圖像文件 模塊 方法 功能 參數(Parameters) 返回值(Returns) Python輸出圖像文件 模塊 方法 功能 參數(Parameters) 參考文章 ? Matplotlib Matplotlib is acomprehensive library for creating static,

目錄

Matplotlib

Python讀入圖像文件

模塊

方法

功能

參數(Parameters)

返回值(Returns)

Python輸出圖像文件

模塊

方法

功能

參數(Parameters)

參考文章


?

Matplotlib

Matplotlib is acomprehensive library for creating static, animated, and interactive visualizations in Python.(2021.4.14,摘自https://matplotlib.org/stable/index.html)

Python讀入圖像文件

模塊

matplotlib.image

This image module supports basic image loading, rescaling and display operations.(2021.4.14,摘自https://matplotlib.org/stable/index.html)

方法

python100例?matplotlib.image.imread(fname,format=None)

功能

Read an image from a file into an array

參數(Parameters)

fname:str or file-like

The image file to read: a filename, a URL, or a file-like object opened in read-binary mode.

Passiing a URL is deprecated. Please open the URL for reading and pass the result to Pillow, e.g. with PIL.Image.open(urllib.request.urlopen(url)).

python圖像增強,format: str, optional

The image file format assumed for reading the data if not given, the format is deduced from the filename. If nothing can be deduced, PNG is tried.

返回值(Returns)

numpy.array

The image data. The returend array has shape

  • (M,N)for grayscale images.
  • (M,N,3)for RGB images.
  • (M,N,4)for RGBA images.

?

Python輸出圖像文件

模塊

python處理文本文件?matplotlib.image

方法

matplotlib.image.imsave(fname,arr,vmin=None,vmax=None,cmap=None,format=None,origin=None,dpi=100,*,metedata=None,pil_kwargs=None)

功能

Save an array as an image file.

參數(Parameters)

fname: str or path-like or file-like

A path or a file-like object to store the image in. if format is not set, then the output format is inferred from the extension of fname, if any, and from rcParams["savefig.format"](default:'png') otherwise. If format is set, it determines the output format.

怎么用python處理數據、arr:array-like

The image data. The shape can be one MxN(luminance), MxNx3(RGB) or MxNx4(RGBA).

vmin,vmax:float,optional

vimin and vmax set the color scaling for the image by fixing the values that map to the colormap color limits. If either vmin or vmax is None, that limit is determined form the arr min/max value.

cmap:str or Colormap, default rcParams["image.cmap"](default: 'viridis')

python作圖、A Colormap instance or registered colormap name. The colormap maps scalar data to colors. It is ignored for RGB(A) data.

format:str,optional

The file format, e.g. 'png','gif','svg',... The behavior when this is unset is documented under fname.

origin:{'upper','lower'},default: rcParams["image.origin"](default: 'upper')

Indicates whether the (0,0) index of the array is in the upper left of lower comer of the axes.

python 文件,dpi:float

The DPI to store in the metadata of the file. This does not affect the resolution of the output image. Depending on file format, this may be rounded to the nearest integer.

metadata:dict,optional

Metadata in the image file. The supported keys depend on the output format, see the documentation of the respective backends for more information.

pil_kwargs:dict,optional

python的輸入、Keyword arguments passed to PIL.Image.Image.save. If the 'pnginfo' key is present, it completely overrides metadata, including the default 'Software' key.

參考文章

https://matplotlib.org/stable/api/image_api.html

?

?

?

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/158739.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息