您的位置:首页 > 编程语言 > Python开发

Python OpenCV学习笔记之:图像读取,显示及保存

2016-12-05 00:00 806 查看
摘要: 代码地址:https://github.com/juxiangwu/tensorflow-learning/tree/master/opencv/core

#-*- coding: utf-8 -*-
# 读取,保存,显示图片
import cv2 as cv

# 读取为灰度图片
img = cv.imread("../../datas/images/fish.jpg",0)

# 保存图片
cv.imwrite("../../datas/images/fish-gray.jpg",img=img)

# 显示图片
cv.imshow("img-gray",img)
'''
# 通过Matplotlib显示图片
#import  matplotlib.pyplot as plt
#plt.imshow(img,cmap='gray',interpolation='bicubic')
#plt.xticks([])
#plt.yticks([])
#plt.show()
#cv.waitKey()
#cv.destroyAllWindows()
'''
cv.waitKey()
cv.destroyAllWindows()
'''
# 等待事件
# key = cv.waitKey(10)
# if key == 27:# ESC
# 销毁所有窗口
#cv.destroyAllWindows()
'''
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息