参考资料写了RGB2YUV(YUV444)的python代码,有时间再来补文字说明。
from PIL import Image
import numpy as np
import cv2
def RGB2YUV_cv2(file, Path_out, show_img = False, show_yuv = False):
img = cv2.imread(file) # cv2 is BGR
b, g, r = cv2.split(img)
if show_img:
cv2.imshow('b', b)
cv2.imshow('g', g)
cv2.imshow('r', r)
cv2.imshow('img', img)
img_yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
y, u, v = cv2.split(img_yuv)
if show_yuv:
cv2.imshow('y', y)
cv2.imshow('u', u)
cv2.imshow('v', v)
cv2