自学内容网 自学内容网

opencv入门基础

1.3灰度图

运行结果如下:

代码如下:

import cv2
img_rgb=cv2.imread("./image/cat.jpg",1)
img_gray=cv2.imread("./image/cat.jpg",0)
cv2.imshow("rgb",img_rgb)
cv2.imshow("gray",img_gray)
print("rgb shape:"+str(img_rgb.shape)+"gray shape:"+str(img_gray.shape))
cv2.waitKey(0)
cv2.destroyAllWindows()

def img_read():
    img_rgb=cv2.imread("./image/cat.jpg",1)
    b,g,r=cv2.split(img_rgb)
    img_merge=cv2.merge(b,g,r)
    cv2.imshow("rgb",img_rgb)
    cv2.imshow("gray",r)
    cv2.imshow("merge",img_merge)
    print("rgb shape:"+str(img_rgb.shape)+"gray shape:"+str(g.shape))
    cv2.waitKey(0)
    cv2.destroyAllWindows()

原文地址:https://blog.csdn.net/yzx991013/article/details/145213013

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!