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).
相关文章
|
计算机视觉
StretchDIBits 直接使用cv::Mat的数据有可能显示错误的问题
StretchDIBits 直接使用cv::Mat的数据有可能显示错误的问题
|
6月前
|
存储 计算机视觉
OpenCV 中 CV_8UC1,CV_32FC3,CV_32S等参数的含义
OpenCV 中 CV_8UC1,CV_32FC3,CV_32S等参数的含义
525 3
|
8月前
|
计算机视觉
【已解决】cv2.imread读取中文名称图片报错或者无法保存中文名图片:使用cv2.imdecode与cv2.imencode解决
【已解决】cv2.imread读取中文名称图片报错或者无法保存中文名图片:使用cv2.imdecode与cv2.imencode解决
|
9月前
|
计算机视觉 Python
opencv cv::Range()和cv::Rect()用于crop来获得感兴趣区域
opencv cv::Range()和cv::Rect()用于crop来获得感兴趣区域
356 0
|
计算机视觉
cv::sort和cv::sortIdx
cv::sort和cv::sortIdx
|
计算机视觉
解决办法:cv::randn(cv::_InputOutputArray const&, cv::_InputArray const&, cv::_InputArray const&)’未定义的引用
解决办法:cv::randn(cv::_InputOutputArray const&, cv::_InputArray const&, cv::_InputArray const&)’未定义的引用
206 0
|
计算机视觉
'cv2' has no attribute '_registerMatType 问题解决
'cv2' has no attribute '_registerMatType 问题解决
4418 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;
|
计算机视觉 Python
Python 路径问题:cv2.error: OpenCV(4.1.0)...size.width>0 && size.height>0 in function ‘cv::imshow‘. 解决方法
Python 路径问题:cv2.error: OpenCV(4.1.0)...size.width>0 && size.height>0 in function ‘cv::imshow‘. 解决方法
618 0
|
计算机视觉 Python
成功解决OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in cv::resize, file C:\proj
成功解决OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in cv::resize, file C:\proj