python opencv cv2.imwrite

python opencv cv2.imwrite

环境说明

opencv 安装

pip install opencv-python

opencv:opencv_python 4.5.5.64

介绍

方法

cv2.imwrite

def imwrite(filename, img, params=None): 

输入

  • filename:保留图片文件的路径,必传
  • img:矩阵,与imread读出的格式相同,必传
  • params=None:特定格式的参数编码,可取范围为:

python opencv cv2.imwrite_第1张图片

输出

  • False:保存失败
  • True:保存成功

示例

import cv2
image_full_path="D:\\tt\\\airplane\\1.png"
image_save_full_path = "D:\\tt\\\airplane\\1_save.png"
# 以图片原有的格式加载
pri_image = cv2.imread(image_full_path, -1)
# 保存
cv2.imwrite(image_save_full_path, pri_image)

你可能感兴趣的:(python,python,opencv,imwrite)