self_example/TensorFlow_eaxmple/OpenCV_try/图像的读取与储存.py

8 lines
530 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import cv2
'''cv2调用了imread方法从当前目录下读取了文件读取时转换为灰度图'''
image = cv2.imread("attribute2-attribute3.png", cv2.IMREAD_GRAYSCALE)
'''这里传递进了2个参数第一个表示图片的存储名称并在存储时图片的类型由png格式改变为jpg格式存储第二个参数为内存中所要存储的目标'''
'''imread()函数会删除所有图片alpha通道的信息imwrite()函数要求输出的图片格式为BGR或者灰度图'''
cv2.imwrite("code2.jpg", image)