计算机视觉opencv - 1 (图片转换为矩阵)

1. 图片的读取和显示

#!/usr/bin/python
# -*-coding:utf-8-*- 
"""
@author: yugengde
@contact: yugengde@163.com
@file : image.py
@time: 2018/2/9 13:38
"""
import cv2import sys

if __name__ == '__main__':
    if len(sys.argv) > 1:
        image = cv2.imread(sys.argv[1], cv2.IMREAD_GRAYSCALE)  # 灰度图片
        # image = cv2.imread(sys.argv[1], cv2.IMREAD_ANYCOLOR)
        # image = cv2.imread(sys.argv[1], cv2.IMREAD_UNCHANGED)
    else:
        print('Usage: pthon first opencv2.py imageFile')

    cv2.imshow('image', image)

    cv2.waitKey(0)
    cv2.destroyAllWindows()

 

posted @ 2018-02-09 15:54  yugengde  阅读(750)  评论(0编辑  收藏  举报