imread(const string& filename, int flags=1)
例如:
//读入图像单通道,即灰度图
ScrImage = imread("C:\\Users\\Desktop\\opencv_1.jpg", 0);
imread函数从文件中加载图像并返回该图像。如果该图像不能被读取(由于文件丢失、权限不正确、不支持或非法的格式等原因),该函数返回一个空的矩阵(Mat中的data项为NULL)。现在已经支持一下的文件格式:
- Windows bitmaps - *.bmp, *.dib (always supported)
- JPEG files - *.jpeg, *.jpg, *.jpe (see the Notes section)
- JPEG 2000 files - *.jp2 (see the Notes section)
- Portable Network Graphics - *.png (see the Notes section)
- WebP - *.webp (see the Notes section)
- Portable image format - *.pbm, *.pgm, *.ppm (always supported)
- Sun rasters - *.sr, *.ras (always supported)
- TIFF files - *.tiff, *.tif (see the Notes section)
flag=-1时,8位深度,原通道
flag=0,8位深度,1通道
flag=1, 8位深度 ,3通道
flag=2,原深度,1通道
flag=3, 原深度,3通道
flag=4,8位深度 ,3通道