发布时间:2019-07-30 10:29:21编辑:auto阅读(1451)
import cv2
2.导入numpy模块
import numpy as np
3.读取当前目录图片
img = cv2.imread("1.jpg")
4.创建图像
emptyImage = np.zeros(img.shape, np.uint8)
5.复制图像
emptyImage2 = img.copy()
6.得到图像副本,并做灰度处理
emptyImage3 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
7.显示图像
cv2.imshow("EmptyImage", emptyImage)
cv2.imshow("EmptyImage1", img)
cv2.imshow("EmptyImage2", emptyImage2)
cv2.imshow("EmptyImage3", emptyImage3)
8.写入保存图片
cv2.imwrite("./cat2.jpg", img, [int(cv2.IMWRITE_JPEG_QUALITY), 5])
cv2.imwrite("./cat3.jpg", img, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
cv2.imwrite("./cat.png", img, [int(cv2.IMWRITE_PNG_COMPRESSION), 0])
cv2.imwrite("./cat2.png", img, [int(cv2.IMWRITE_PNG_COMPRESSION), 9])
9.窗口等待
cv2.waitKey(0)
cv2.destroyAllWindows()
上一篇: 实现的简单python例子
下一篇: Centos 下升级python
47490
45792
36789
34321
28958
25594
24441
19608
19109
17630
5463°
6046°
5568°
5636°
6571°
5374°
5375°
5882°
5853°
7167°