在图像处理过程中,经常会遇到YUV与RGB之间的转换,这个转换有不同标准,有多种转换公式,
有时,由于没有成对的匹配上,导致了效果异常。现在总结各种标准的转换公式。
主要分BT601,BT709和BT2020,三种标准下都有full range和limit range的区分。这里主要列除了转换矩阵,对于limit range,Y有偏置,对8bit是np.array([16,128,128]),full range的偏置为np.array([0,128,128])。
r2y_limit_range_601 = np.array([
[ 0.257, 0.504, 0.098],
[-0.148, -0.291, 0.439],
[ 0.439, -0.368, -0.0714]])
y2r_limit_range_601 = np.array([
[1.1644, 0.0, 1.5958],
[1.1644, -0.3938, -0.8130],
[1.1644, 2.0172, -0.0]])
r2y_full_range_601 = np.array([
[ 0.299, 0.587, 0.114],
[-0.1687, -0.3313, 0.5],
[ 0.5, -0.4187, -0.0813]])
y2r_full_range_601 = np.array([
[1.0, -0.0, 1.402],
[1.0, -0.3441, -0.7141],
[1.0, 1.772, -0.0]])
r2y_limit_range_709 = np.array([
[ 0.1826, 0.6142, 0.0620],
[-0.1006, -0.3386, 0.4392],
[ 0.4392, -0.3989, -0.0403]])
y2r_limit_range_709 = np.array([
[1.1644, 0.0, 1.7927],
[1.1644, -0.2132, -0.5329],
[1.1644, 2.1124, -0.0]])
r2y_full_range_709 = np.array([
[ 0.2126, 0.7152, 0.0722],
[-0.1146, -0.3854, 0.500],
[ 0.500, -0.4542, -0.0458]])
y2r_full_range_709 = np.array([
[1.0, 0.0, 1.5748],
[1.0, -0.1873, -0.4681],
[1.0, 1.8556, 0.0]]
)
r2y_limit_range_2020 = np.array([
[0.2256, 0.5823, 0.0509],
[-0.1227, -0.3166, 0.4392],
[0.4392, -0.4039, -0.0353]
])
y2r_limit_range_2020 = np.array([
[1.1644, -0.0, 1.6787],
[1.1644, -0.1873, -0.6504],
[1.1644, 2.1418, 0.0]])
r2y_full_range_2020 = np.array([
[ 0.2627, 0.6780, 0.0593],
[-0.1396, -0.3604, 0.500],
[ 0.500, -0.4598, -0.0402]
])
y2r_full_range_2020 = np.array([
[1.0, -0.0, 1.4746],
[1.0, -0.1646, -0.5714],
[1.0, 1.8814, -0.0]]
)