opencv | imwrite

//一般用法
bool cv::imwrite(const String & filename,
                 InputArray 	img,
                 const std::vector<int>& params = std::vector<int>())	
//python用法
retval=cv.imwrite(filename,img[, params])

Saves an image to a specified file.

保存图像到指定文件。

The function imwrite saves the image to the specified file. The image format is chosen based on the filename extension (see cv::imread for the list of extensions). Only 8-bit (or 16-bit unsigned (CV_16U) in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use Mat::convertTo , and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O functions to save the image to XML or YAML format.

这个函数将图像保存到指定文件。图像类型的选择基于文件扩展名(见cv::imread的扩展名列表)。只有8位(或16位无符号(CV_16U)的PNG,JPEG 2000,和TIFF)的单通道或3通道(‘BGR’通道)的图像可以使用这个函数。如果格式、深度或者通道要求不同,在保存之前,可以使用Mat::convertTo,和cv::cvtColor来转换它。或者,使用FileStorag的I/O函数来保存到XML或YAML格式。

It is possible to store PNG images with an alpha channel using this function. To do this, create 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535.

如果使用这个函数来保存具有alpha通道的PNG图像。需要创建一个8位(或16位)的四通道BGRA图像,最后一个通道为alpha。完全透明的像素,alpha应该设为0,完全不透明得像素,alpha应该设为255/65535。

Parameters 

filename Name of the file.
img Image to be saved.
params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags

猜你喜欢

转载自blog.csdn.net/qq_39419087/article/details/82188498