当前位置:网站首页>Color space conversion in video tonemapping (HDR to SDR) (bt2020 to bt709, YCbCr, YUV and RGB)
Color space conversion in video tonemapping (HDR to SDR) (bt2020 to bt709, YCbCr, YUV and RGB)
2022-06-30 00:02:00 【q274488181】
I press , Recently doing video TM Related work of , Specifically, given a HDR video (10bit Of YUV420 Format ), To do it TM, Wrote an algorithm, but there is always a very outrageous color difference , Especially the red and blue channels . After careful examination, it was found that it was obtained HDR The color space of the video is BT2020 Of , But after the conversion SDR The video is BT709 Of , You need to downgrade the color space before processing . Here's a record of the process .
First post two addresses
These are both ITU A standard programmatic document . The first document talks about how to BT709 go to 2020( But only RGB The signal ), The second one talks about how to BT2020 The switch to BT709( Include YUV、RGB How to deal with it ).
In the literature [2] in , A simple and crude diagram is given

E'RGB refer to “ Normalized nonlinearity RGB value ”, and E_RGB refer to “ Normalized linearity RGB value ”.
But in the algorithm , The data I got was 10bit Of YUV420 data , So we need to 10bitYUV420 Data conversion to E'RGB. How to turn ? Not mentioned in the literature . But the literature [1] How will 709 The switch to 2020 when , Give a picture

In addition to here E'RGB and E_RGB outside , We have the E'YCBCR and D'YCBCR. among E'YCBCR refer to “ The normalized YCBCR value ”, and D'YCBCR refer to “ Quantized YCBCR value ”
So I understand here , What I get at the input of the algorithm is called 10bitYUV420 data , It's actually this D'YCBCR value . So next , We combine two literatures , The corresponding process can be deduced .
Step 1. take D’YCbCr(2020) To E’YCbCr(2020)
In fact, it is the antiprocess of the following process

Simple deduction , have to
E_Y = ((D_Y / 4) - 16) / 219
E_Cb = ((D_Cb / 4) - 128) / 224
E_Cr = ((D_Cr / 4) - 128) / 224Step 2. take E’YCbCr(2020) To E’RGB(2020)
The literature [1] The inverse process is given in

So here we just do a simple matrix inversion ( Here the inverse is given directly )
It should be noted that , In the code given below E_YCbCr and E_RGB Such a variable , Their shapes are height x width x 3 Of , So here we do such a transformation of linear algebra . Use of is (AxB)T = BT x AT This is the nature of . This method is used in many places below , I won't explain it later .
m_YCbCr2020_to_RGB2020 = np.array([[1.00000000e+00, -7.82308321e-18, 1.47460000e+00],
[1.00000000e+00, -1.64553127e-01, -5.71353127e-01],
[1.00000000e+00, 1.88140000e+00, 2.38961873e-17]])
E_RGB = np.matmul(E_YCbCr, m_YCbCr2020_to_RGB2020.T)Step 3. take E’RGB(2020) To E RGB(2020)
E_RGB = np.power(E_RGB, 2)
# Another version is
# E_RGB = np.power(E_RGB, 2.4)Step 4. take E RGB(2020) To E RGB(709)
m_RGB2020_to_RGB709 = np.array([[1.66051121, -0.58771059, -0.07280062],
[-0.12456141, 1.13296051, -0.00839911],
[-0.01816769, -0.1005606, 1.11872828]])
E_RGB = np.matmul(E_RGB, m_RGB2020_to_RGB709.T)Step 5. take E RGB(709) To E’RGB(709)
E_RGB = np.power(E_RGB, 1/2)
# Another version is
# E_RGB = np.power(E_RGB, 1/2.4)Step 6. E’RGB(709) To D’RGB(709)
【 Here is to 10bit As an example of , If it is 8bit, Get rid of the back *4 that will do 】
D_RGB = ((E_RGB * 219 + 16) * 4).astype("uint16")After this conversion , There is no color deviation problem .
边栏推荐
- QT learning 02 GUI program example analysis
- [LeetCode] 只出现一次的数字【136】
- New CorelDRAW technical suite2022 latest detailed function introduction
- Solr基础操作14
- QT learning 07 coordinate system in QT
- [Shangshui Shuo series] day 8
- Digital collection of cultural relics, opening a new way of cultural inheritance
- 云服务器的安全设置常识
- Zhongang Mining: Fluorite helps the construction and development of lithium battery in fluorine industry
- 500 error occurred after importing skins folder into solo blog skin
猜你喜欢

西门子低代码 9.14版本: 满足不同需求

How to write controller layer code gracefully?

Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column

6.29日刷题题解

QT learning 01 GUI program principle analysis

架构实战营模块5作业
solo 博客皮肤导入 skins 文件夹后出现 500 错误

【一起上水硕系列】Day 8

FPGA Development (2) -- IIC communication

Zhongang Mining: Fluorite helps the construction and development of lithium battery in fluorine industry
随机推荐
HPE launched ARM CPU general server product
QT learning 05 introduction to QT creator project
AI首席架构师9-胡晓光 《飞桨模型库与行业应用》
西门子低代码 9.14版本: 满足不同需求
Machine learning: the concept and application of VC dimension
JVM之栈空间
雲和恩墨蓋國强,識別它、抓住它,在國產數據庫沸騰以前
[LeetCode] 只出现一次的数字【136】
Shell operator
QT learning 04 Hello QT
西门子低代码平台通过Database Connector 连接Mysql 实现增删改查
Construction of module 5 of actual combat Battalion
大厂试水 HPE推出Arm CPU通用服务器产品
QT learning 07 coordinate system in QT
Solr基础操作11
这个简单的小功能,半年为我们产研团队省下213个小时
modelsim的TCL脚本的define incdir命令解析
小程序插件接入、开发与注意事项
xutils3传集合
Siemens low code platform connects MySQL through database connector to realize addition, deletion, modification and query