Notes:
imread uses the Python Imaging Library (PIL) to read an image. The following notes are from the PIL documentation.使用Python图像库(PIL)读取图像
mode can be one of the following strings:
'L' (8-bit pixels, black and white)(8位像素,黑白)
'P' (8-bit pixels, mapped to any other mode using a color palette)(8位像素,使用调色板映射到任何其他模式)
'RGB' (3x8-bit pixels, true color)(3x8位像素,真彩色)
'RGBA' (4x8-bit pixels, true color with transparency mask)(4x8位像素,带透明蒙版的真彩色)
'CMYK' (4x8-bit pixels, color separation)(4x8位像素,分色)
'YCbCr' (3x8-bit pixels, color video format)(3x8位像素,彩色视频格式)
'I' (32-bit signed integer pixels)(32位有符号整数像素)
'F' (32-bit floating point pixels)(32位浮点像素)
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).
PIL还提供了对某些特殊模式的有限支持,包括" LA"(带L的" L")," RGBX"(带填充的真彩色)和" RGBa"(带预乘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"," I"或" F")时,该库使用ITU-R 601-2亮度转换:
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'.
展平为True时,将使用" F"模式转换图像。当mode不为None且flatten为True时,将首先根据mode转换图像,然后使用" F"模式将结果展平。
python复制代码
import scipy
from scipy import misc
imgpath='image/file/name.tif'
img=misc.imread(imgpath)
#or
from scipy import ndimage
img = ndimage.imread(imgpath, mode='RGB')