Mat imread(const string& filename, int flags=1)
| Parameters |
filename – Name of file to be loaded. flags – 载入图像时对通道数的处理
- >0 强制以3通道图像载入 3-channels
- =0 强制以灰度图像载入 grayscale
- <0 按图像的原始颜色载入 as-is
|
| 支持的图像类型 |
Windows bitmaps - *.bmp, *.dib (always supported) JPEG files - *.jpeg, *.jpg, *.jpe (see Note2 ) JPEG 2000 files - *.jp2 (see Note2 ) Portable Network Graphics - *.png (see Note2 ) Portable image format - *.pbm, *.pgm, *.ppm (always supported) Sun rasters - *.sr, *.ras (always supported) TIFF files - *.tiff, *.tif (see Note2 )
|
bool imwrite(const string& filename, const Mat& img, const vector<int>& params=vector<int>())
| Parameters |
filename – Name of the file. img – The image to be saved. params – The format-specific save parameters, encoded as pairs paramId_1, paramValue_1, paramId_2, paramValue_2, ... . The following parameters are currently supported: In the case of JPEG it can be a quality ( CV_IMWRITE_JPEG_QUALITY ), from 0 to 100 (the higher is the better), 95 by default. In the case of PNG it can be the compression level ( CV_IMWRITE_PNG_COMPRESSION ), from 0 to 9 (the higher value means smaller size and longer compression time), 3 by default. In the case of PPM, PGM or PBM it can a binary format flag ( CV_IMWRITE_PXM_BINARY ), 0 or 1, 1 by default.
|
| Sample |
imread/imwrite sample
|