函数原型
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );
参数说明
第一个参数是图片路径名称,强烈建议使用/作为目录的分割符号,例如
第二参数具有如下的值,说明了读取过程中是否需要进行像素的操作,例如取值0,表示读取过程中将像素转换为灰度值,默认参数是1, 表示不改变原图像的像素
enum ImreadModes {
IMREAD_UNCHANGED = -1, //!< If set, return the loaded p_w_picpath as is (with alpha channel, otherwise it gets cropped).
IMREAD_GRAYSCALE = 0, //!< If set, always convert p_w_picpath to the single channel grayscale p_w_picpath.
IMREAD_COLOR = 1, //!< If set, always convert p_w_picpath to the 3 channel BGR color p_w_picpath.
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit p_w_picpath when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR = 4