要将 OpenCV 中的 BGR 图像保存为 PNG 格式,可以使用 cv2.imwrite()
函数。以下是保存 BGR 图像为 PNG 格式的示例代码:
import cv2
# 读取 BGR 图像
img_bgr = cv2.imread('example.jpg')
# 保存为 PNG 格式
cv2.imwrite('example.png', img_bgr)
在上面的代码中,我们首先使用 cv2.imread()
函数读取了一个 BGR 图像。然后,使用 cv2.imwrite()
函数将该图像保存为 PNG 格式。`cv2.imw