opencv - what does flag -1 in imread of opencv mean
问题描述
I see the code: Mat imgOrg = imread( fileName, -1 );
. What kind of flag imreadmodes the argument -1
refers to ?
解决方案
标志和对应的含义:来自 OpenCV imgcodecs.hpp
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image.
IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
所以-1
意味着UNCHANGED
推荐阅读
- sql-server - SQL Server Management Studio 2008R2 与 SQL Server 2017 - 兼容性?
- python - 如何编写两个背靠背(非同时)multiprocessing.dummy 任务?
- python - 如何遍历python类对象中的所有变量(不将它们转换为字符串)?
- r - 如何在 r 中创建和打印 wordcloud
- c - 堆栈段 C 数组
- javascript - 按钮 onclick 事件不会触发
- javascript - 如何根据另一个 div jQuery 中的内容显示 div
- javascript - 带有 Vue.js 的 Laravel 5.7
- angular - firebase 身份验证无法从 iPhone 上的 facebook Messenger 工作
- r - R string matching and replace