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

from init.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函数来保存图片

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dontla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值