作业四:
分别在三个窗口中显示图像的RGB三个通道
参考链接:
https://blog.csdn.net/huanglu_thu13/article/details/52332695
import cv2
import numpy
img = cv2.imread("Tomylove1.png")
b, g, r = cv2.split(img)
cv2.imshow("Blue 1", b)
cv2.imshow("Green 1", g)
cv2.imshow("Red 1", r)
def get_red(img):
redImg = img[:,:,2]
return redImg
def get_green(img):
greenImg = img[:,:,1]
return greenImg
def get_blue(img):
blueImg = img[:,:,0]
return blueImg
b = get_blue(img)
g = get_green(img)
r = get_red(img)
cv2.imshow("Blue 2", b)
cv2.imshow("Green 2", g)
cv2.imshow("Red 2", r)
cv2.waitKey (0)
cv2.destroyAllWindows()