scipy.misc

python scipy.misc.imread_scipy.misc.imread()函数解析
weixin_39828457 2020-12-08 08:22:07 264 收藏
文章标签: python scipy.misc.imread

scipy.misc.imread()函数用于从文件中读取图像作为数组。

scipy.misc.imread(name,

flatten=False,

mode=None

)

参数:

name:str或file对象。要读取的文件名或文件对象。

flatten:bool,可选。如果为True,则将颜色层展平为单个灰度图层。

mode:str,可选。将图像转换为例如的模式’RGB’。

返回:

imread:ndarray。通过读取图像获得的阵列。

注意:

“”"

Notes


imread uses the Python Imaging Library (PIL) to read an image.

The following notes are from the PIL documentation.

mode can be one of the following strings:

  • ‘L’ (8-bit pixels, black and white)

  • ‘P’ (8-bit pixels, mapped to any other mode using a color palette)

  • ‘RGB’ (3x8-bit pixels, true color)

  • ‘RGBA’ (4x8-bit pixels, true color with transparency mask)

  • ‘CMYK’ (4x8-bit pixels, color separation)

  • ‘YCbCr’ (3x8-bit pixels, color video format)

  • ‘I’ (32-bit signed integer pixels)

  • ‘F’ (32-bit floating point pixels)

PIL also provides limited support for a few special modes, including

‘LA’ (‘L’ with alpha), ‘RGBX’ (true color with padding) and ‘RGBa’

(true color with premultiplied alpha).

When translating a color image to black and white (mode ‘L’, ‘I’ or

‘F’), the library uses the ITU-R 601-2 luma transform::

L = R * 299/1000 + G * 587/1000 + B * 114/1000

When flatten is True, the image is converted using mode ‘F’.

When mode is not None and flatten is True, the image is first

converted according to mode, and the result is then flattened using

mode ‘F’.

“”"

以下是翻译:

imread使用Python Imaging Library(PIL)读取图像。以下注释来自PIL文档。

mode可以是以下字符串之一:

‘L’(8位像素,黑白)

‘P’(8位像素,使用调色板映射到任何其他模式)

‘RGB’(3x8位像素,真彩色)

‘RGBA’(4x8位像素,带透明蒙版的真彩色)

‘CMYK’(4x8位像素,分色)

‘YCbCr’(3x8位像素,彩色视频格式)

‘I’(32位有符号整数像素)

‘F’(32位浮点像素)

PIL还为一些特殊模式提供有限的支持,包括’LA’(带有alpha的’L’),‘RGBX’(带填充的真彩色)和’RGBa’(带有预乘alpha的真彩色)。

将彩色图像转换为黑白(模式“L”,“I”或“F”)时,库使用ITU-R 601-2亮度转换:

L=R∗299/1000+G∗587/1000+B∗114/1000L=R299/1000+G587/1000+B*114/1000L=R∗299/1000+G∗587/1000+B∗114/1000

当flatten为True时,使用mode“F”转换图像。当mode不是None并且flatten为True时,首先根据mode转换图像,然后使用mode’F’flatten结果。

标签:color,misc,像素,scipy,mode,imread,bit,pixels,1000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值