2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > python opencv imwrite()方法 cv :: ImwriteFlags (写入图片 保存图片)

python opencv imwrite()方法 cv :: ImwriteFlags (写入图片 保存图片)

时间:2019-08-27 20:27:45

相关推荐

python opencv imwrite()方法 cv :: ImwriteFlags (写入图片 保存图片)

frominit.py:

opencv版本4.1.0,不同版本也许doc稍有不同

def imwrite(filename, img, params=None): # real signature unknown; restored from __doc__"""imwrite(filename, img[, params]) -> retval. @brief 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). In general, only 8-bit. single-channel or 3-channel (with 'BGR' channel order) images. can be saved using this function, with these exceptions:· imwrite函数将图像保存到指定文件。 图像格式是根据文件扩展名选择的(扩展名列表请参见cv :: imread)。 · 通常,使用此功能只能保存8位单通道或3通道(具有“ BGR”通道顺序)图像,但以下情况除外:. - 16-bit unsigned (CV_16U) images can be saved in the case of PNG, JPEG 2000, and TIFF formats. - 32-bit float (CV_32F) images can be saved in PFM, TIFF, OpenEXR, and Radiance HDR formats;· 对于PNG,JPEG 2000和TIFF格式,可以保存16位无符号(CV_16U)图像;·可以PFM,TIFF,OpenEXR和Radiance HDR格式保存32位浮点(CV_32F)图像;. 3-channel (CV_32FC3) TIFF images will be saved using the LogLuv high dynamic range encoding. (4 bytes per pixel). - PNG images with an alpha channel can be saved 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 (see the code sample below).·使用LogLuv高动态范围编码(每像素4个字节)将保存3通道(CV_32FC3)TIFF图像-使用此功能可以保存具有alpha通道的PNG图像。 ·为此,创建8位(或16位)4通道图像BGRA,其中alpha通道位于最后。 ·完全透明的像素应将alpha设置为0,完全不透明的像素应将alpha设置为255/65535(请参见下面的代码示例)。. . 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.··如果格式,深度或通道顺序不同,请在保存之前使用Mat :: convertTo和cv :: cvtColor进行转换。 ·或者,使用通用的FileStorage I / O功能将图像保存为XML或YAML格式。. . The sample below shows how to create a BGRA image and save it to a PNG file. It also demonstrates how to set custom. compression parameters:·下面的示例演示如何创建BGRA图像并将其保存到PNG文件。 它还演示了如何设置自定义压缩参数:. @include snippets/imgcodecs_imwrite.cpp. @param filename Name of the file. 文件名。. @param img Image to be saved. 要保存的图像。. @param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags特定格式的参数编码为对(paramId_1,paramValue_1,paramId_2,paramValue_2等)。请参见cv :: ImwriteFlags"""pass

Doc中所指cv :: ImwriteFlags:链接

参考文章:OpenCV笔记1:用imwrite函数来保存图片

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。