在调用opencv的imread(filename, flags=None)函数时,后面有个flags=None参数,但打开文档轻描淡写,不知该参数上哪找去,用全局搜索也搜不到,莫非要到官网查?(擦汗’’)
打开官网,有个Online documentation,点它:
然后找到自己opencv版本点进去,我的是这个(如果不知道自己opencv版本可以在控制台执行pip list
查看):
点进去后右上角搜索就ok了:
IMREAD_UNCHANGED
Python: cv.IMREAD_UNCHANGED
If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
IMREAD_GRAYSCALE
Python: cv.IMREAD_GRAYSCALE
If set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR
Python: cv.IMREAD_COLOR
If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH
Python: cv.IMREAD_ANYDEPTH
If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR
Python: cv.IMREAD_ANYCOLOR
If set, the image is read in any possible color format.
IMREAD_LOAD_GDAL
Python: cv.IMREAD_LOAD_GDAL
If set, use the gdal driver for loading the image.
IMREAD_REDUCED_GRAYSCALE_2
Python: cv.IMREAD_REDUCED_GRAYSCALE_2
If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_REDUCED_COLOR_2
Python: cv.IMREAD_REDUCED_COLOR_2
If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_REDUCED_GRAYSCALE_4
Python: cv.IMREAD_REDUCED_GRAYSCALE_4
If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_REDUCED_COLOR_4
Python: cv.IMREAD_REDUCED_COLOR_4
If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_REDUCED_GRAYSCALE_8
Python: cv.IMREAD_REDUCED_GRAYSCALE_8
If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_REDUCED_COLOR_8
Python: cv.IMREAD_REDUCED_COLOR_8
If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
IMREAD_IGNORE_ORIENTATION
Python: cv.IMREAD_IGNORE_ORIENTATION
If set, do not rotate the image according to EXIF's orientation flag.
参考文章:python opencv imread()函数 (从文件加载图像)