zoukankan      html  css  js  c++  java
  • OpenCV for Python常用命令

     

    读取图像首先要导入OpenCV

    import cv2

    OpenCV目前支持读取bmpjpgpngtiff等常用格式。

    //读取图片

    img2 = cv2.imread('out-0022.jpg')

    //显示图片

    //创建窗口,窗口显示图片

    cv2.namedWindow("Image")

    cv2.imshow("Image", img2)

    //保持图像显示

    cv2.waitKey (0)

    //复制图片

    //import numpy as np

    img3= img2.copy()

    //保存图像

    cv2.imwrite("./result.jpg", img3)

    //分离通道

    b, g, r = cv2.split(img)  

    cv2.imshow("Blue", r)  

    cv2.imshow("Red", g)  

    cv2.imshow("Green", b)

    b = cv2.split(img)[0]  

    g = cv2.split(img)[1]  

    r = cv2.split(img)[2]

    b = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)  

    g = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)  

    r = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)  

      

    b[:,:] = img[:,:,0]  

    g[:,:] = img[:,:,1]  

    r[:,:] = img[:,:,2]

    //合并通道

    merged = cv2.merge([b,g,r])

    mergedByNp = np.dstack([b,g,r])

    参考的文章及感觉不错的文章

    http://blog.csdn.net/sunny2038/article/details/9080047

    http://python.jobbole.com/85178/

    计算机视觉编程http://yongyuan.name/pcvwithpython/chapter10.html

    绘图操作 http://blog.csdn.net/thefutureisour/article/details/7523925

  • 相关阅读:
    api自动化工具集成metersphere
    gitlab+github使用记录
    docker基本操作
    linux指标分析
    python的break和continue
    linux基本性能指标语法
    jmeter标准流程设置
    postman
    jmeter本地启动
    对浮动的一些个人理解
  • 原文地址:https://www.cnblogs.com/vincentqliu/p/7501221.html
Copyright © 2011-2022 走看看