Python#RGB-YCrBr

def RGB_YCbCr(img):
    b, g, r = cv2.split(img)
    Y = 0.114 * b + 0.587 * g + 0.299 * r
    Cr = np.uint8((r - Y)*0.713 + 128)
    Cb = np.uint8((b - Y)*0.564 + 128)
    Y = np.uint8(Y) 	# change data type
    result = cv2.merge((Y, Cb, Cr))
    cv2.imshow("Y channel", Y)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    cv2.imshow("Cb channel", Cb)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    cv2.imshow("Cr channel", Cr)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    return result

 

你可能感兴趣的:(python)