python + opencv 学习系列 1 : Getting Started with Images
2015-10-03 22:50
721 查看
本文主要是根据 opencv 官网中 使用 Python的 教程写的,主要是为了个人学习记忆。
本节学习官网地址:
http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_image_display/py_image_display.html#display-image
下面给出代码整合以及注释
本节学习官网地址:
http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_image_display/py_image_display.html#display-image
下面给出代码整合以及注释
def startWithImage(): ''' load and display an image ''' #load an color image in grayscale grayImage = cv2.imread("girl and green.jpg", 0) #中文标题不行 待解 #display an image cv2.namedWindow("girl and green", cv2.WINDOW_AUTOSIZE) cv2.imshow("girl and green", grayImage) cv2.waitKey(10000) cv2.destroyAllWindows() #write an image cv2.imwrite("gary girlAndGreen.jpg", grayImage ) def SumItUp(): ''' copy from opencv python tutorial ''' grayImage = cv2.imread("girl and staircase.jpg", 0) cv2.imshow("girl and staircase",grayImage) k = cv2.waitKey(0 ) if k == 27: # wait for ESC key to exit cv2.destroyAllWindows() elif k == ord("s"): # wait for "s" key to save and exit cv2.imwrite("gray girlAndStaircase.jpg", grayImage ) cv2.destroyAllWindows() def usingMatplotlib(): ''' Matplotlib is a plotting library for Python which gives you wide variety of plotting methods. ''' from matplotlib import pyplot as plt grayImage = cv2.imread("girl and sexy.jpg", 0 ) plt.imshow(grayImage, cmap='gray', interpolation= 'bicubic') plt.xticks([]), plt.yticks([] ) # to hide tick values on X and Y axis plt.show() def mainPy(): ''' python入口函数 ''' #startWithImage( ) #SumItUp() usingMatplotlib() if __name__ == "__main__": mainPy( )
相关文章推荐
- Python文件名称与将导入的模块名相同会出现的问题
- 分词算法的python实现(正向最大匹配法)
- python第一课~兔子在欢乐的度假期~
- python之Numpy使用
- 【python问题系列--2】脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
- 1.Python深入_对象的属性
- python闭包
- Python核心编程笔记 - 杂记第1章至第8章
- 如何在Windows 下安装Python
- 【Python】二分查找算法
- 八大排序算法的Python实现
- 【Python之旅】第五篇(三):Python Socket多线程并发
- 2.Python深入_上下文管理器
- python学习笔记——自定义模块导入
- 【Python之旅】第五篇(二):Python Socket单线程+阻塞模式
- 【Python之旅】第五篇(二):Python Socket单线程+阻塞模式
- Python学习笔记<list,tuple,range再探>
- Python学习笔记<list,tuple,range再探>
- 【Python之旅】第五篇(一):Python Socket通信原理
- 【Python之旅】第五篇(一):Python Socket通信原理