CV2.imread flag参数说明

简介: CV2.imread flag参数说明

这里主要记录一下imread的第二个参数flag,再实际的使用中,可以不使用这个参数,则其取的是默认值。

一般情况下,flag有3种取值:

-1:原图

0:灰度图

1:彩色图

若不使用flag,则默认值为1,即彩色图像。


文档中是这么写的:

Flags specifying the color type of a loaded image:

  • CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
  • CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
  • CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one
  • >0 Return a 3-channel color image.
  •  Note
       In the current implementation the alpha channel, if any, is stripped from the output image. Use negative value if you need the alpha channel.
  • =0 Return a grayscale image.
  • <0 Return the loaded image as is (with alpha channel).
相关文章
|
7月前
|
计算机视觉
StretchDIBits 直接使用cv::Mat的数据有可能显示错误的问题
StretchDIBits 直接使用cv::Mat的数据有可能显示错误的问题
|
4月前
|
计算机视觉 Python
opencv cv::Range()和cv::Rect()用于crop来获得感兴趣区域
opencv cv::Range()和cv::Rect()用于crop来获得感兴趣区域
41 0
|
7月前
|
计算机视觉
|
7月前
|
计算机视觉
cv::imread读取文件失败
cv::imread读取文件失败
|
8月前
|
计算机视觉 Python
cv2 resize 与reshape的区别
cv2 resize 与reshape的区别
|
计算机视觉
解决办法:cv::randn(cv::_InputOutputArray const&, cv::_InputArray const&, cv::_InputArray const&)’未定义的引用
解决办法:cv::randn(cv::_InputOutputArray const&, cv::_InputArray const&, cv::_InputArray const&)’未定义的引用
160 0
成功解决AttributeError: module &#39;cv2.cv2&#39; has no attribute &#39;CV_CAP_PROP_FPS&#39;和 &#39;CV_CAP_PROP_FRAME_WIDTH&#39;
成功解决AttributeError: module &#39;cv2.cv2&#39; has no attribute &#39;CV_CAP_PROP_FPS&#39;和 &#39;CV_CAP_PROP_FRAME_WIDTH&#39;
|
存储 计算机视觉
ImageMagick 的 Image 和 OpenCV 的 cv::Mat 如何转换
ImageMagick 的 Image 和 OpenCV 的 cv::Mat 如何转换
346 0
|
计算机视觉 Python
PIL.Image.open和cv2.imread的比较与相互转换
PIL.Image.open读入的是RGB顺序,而opencv中cv2.imread读入的是BGR通道顺序 。cv2.imread会显示图片更蓝一些。
376 0
PIL.Image.open和cv2.imread的比较与相互转换
|
API 计算机视觉