文章选自:
一、imread说明
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );
功能:读取图像参数:@param filename 导入图像路径.@param flags 图像类型标识位enum ImreadModes {IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.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.};
目前支持的图像格式:
-
Windows 位图 - *.bmp, *.dib
-
JPEG 文件 - *.jpeg, *.jpg, *.jpe
-
JPEG 2000 文件 - *.jp2
-
可移植网络图形 - *.png
-
WebP - *.webp
-
AVIF - *.avif
-
可移植图像格式 - *.pbm, *.pgm, *.ppm, *.pxm, *.pnm
-
PFM 文件 - *.pfm
-
Sun 光栅 - *.sr, *.ras
-
TIFF 文件 - *.tiff, *.tif
-
OpenEXR 图像文件 - *.exr
-
Radiance HDR - *.hdr, *.pic
-
GDAL 支持的光栅和矢量地理空间数据
二、imreadmulti说明
bool imreadmulti(const String& filename, CV_OUT std::vector<Mat>& mats, int flags = IMREAD_ANYCOLOR);功能:从指定文件加载多通道图像到 Mat对象的向量中参数:@param filename 要加载的文件名。@param mats 一个 Mat 对象的向量,用于存储每一通道。@param flags 可以取 cv::ImreadModes 的值,默认值为 cv::IMREAD_ANYCOLOR。