Convert tricky system of equations into coefficient matrix

91 Views Asked by At

I have the following system of equations (taken from this wiki page https://en.wikipedia.org/wiki/YUV#SDTV_with_BT.601), and I am trying to understand how they convert this:

$W_R = 0.299$

$W_G = 1 - W_R - W_B$

$W_B = 0.114$

$U_\max = 0.436$

$V_\max = 0.615$

$ $

$Y' = W_RR + W_GG + W_BB$

$U = U_\max \frac{B-Y'}{1-W_B}$

$V = V_\max \frac{R-Y'}{1-W_R}$

Into the matrix:

$$ \left[ \begin{matrix} Y'\\ U \\ V \\ \end{matrix} \right] = \left[ \begin{matrix} 0.299& 0.587 & 0.114 \\ -0.14713 & -0.28886 & 0.436 \\ 0.615 & -0.51499 & -0.10001 \\ \end{matrix} \right] \left[ \begin{matrix} R\\ G \\ B \\ \end{matrix} \right] $$

I can see how the $Y'$ row is constructed by simply moving out the coefficients, but no amount of simplification that I am able to understand has helped me in re-arranging the $U$ and $V$ equations to similar effect.

I tried breaking the $Y'$ constant in the $U$ equation back into its component pieces, and then simplifying (through wolfram alpha) gave me:

$U_\max \frac{B - (W_RR + W_GG + W_BB)}{1-W_B}$

Which I re-arranged to the following:

$(-RU_\max W_R) + (-GU_\max W_G) + (-BU_\max W_B) + (BU_\max) + (-U_\max W_B)$

Which allowed be to remove the $R$ and $G$ components, but I don't know how to then remove $B$. I'm sure I'm not doing things correctly.

Can anyone offer any assistance?

Thanks

3

There are 3 best solutions below

0
On BEST ANSWER

With a little help from the above posters (and a quick maths lesson from @quick7silver ), I realised where I was going wrong. My initial problem wasn't quite as I had described, as I also wanted my result matrix to incorporate the original variables (as I was transcribing the formula into a computer program), which meant I couldn't perform the initial variable substitution which greatly simplified the problem for the other answerers.

My final working for $U$ was as follows:

$U = U_\max \frac{B-(W_RR+W_GG+W_BB)}{1-W_B}$

$\phantom{U} = U_\max \frac{B+(-W_RR-W_GG-W_BB)}{1-W_B}$

$\phantom{U} = U_\max \frac{-W_RR - W_GG + (1-W_B)B}{1-W_B}$

$\phantom{U} = \frac{U_\max}{1-W_B} -W_RR-W_GG+(1-W_B)B$

$\phantom{U} = \frac{U_\max.-W_RR}{1-W_B} - \frac{U_\max.W_GG}{1-W_B} + \frac{U_\max.(1-W_B)B}{1-W_B}$

$\phantom{U} = -U_\max\frac{W_RR}{1-W_B} - U_\max\frac{W_GG}{1-W_B} + U_\max B$

Which when incorporated into the final matrix: $$ \left[ \begin{matrix} W_R & W_G & W_B \\ \frac{-U_\max W_R}{1-W_B} & \frac{-U_\max W_G}{1-W_B} & U_\max \\ V_\max & \frac{-V_\max W_G}{1-W_R} & \frac{-V_\max W_B}{1-W_R} \\ \end{matrix} \right] $$

Thanks a lot for all your help!

0
On

You have:

$$U = U_\max \frac{B-Y'}{1-W_B} = 0.436 \dfrac{B - Y'}{1 - 0.114} = 0.492099(B -(0.114 B+0.587 G+0.299 R))$$

This simplifies to (the second row):

$$0.492099(0.886 B-0.587 G-0.299 R) = 0.436 B-0.288862 G-0.147138 R$$

Rearranging the last expression to be in the matrix order:

$$-0.147138 R -0.288862 G + 0.436 B$$

Seeing this, can you do the third row?

0
On

It's not as complicated as you might think. The first row should be easy: $$Y' = 0.299R+0.587G+0.114B$$ For the second row, we know the expression for $U$: $$\begin{align} U &= \frac{U_{\text{max}}}{1-W_B}B\,-\frac{U_{\text{max}}}{1-W_B}Y' \\ &= -\frac{U_{\text{max}}}{1-W_B}(0.299R)-\frac{U_{\text{max}}}{1-W_B}(0.587G)-\frac{U_{\text{max}}}{1-W_B}(0.114-1)B \end{align}$$

where we have substituted $Y'$ and reorganized into the components $R,G,B$. Do note that $\frac{U_{\text{max}}}{1-W_B}=0.492$ is just a number.

For the third row, the expression for $V$: $$\begin{align} V &= \frac{V_{\text{max}}}{1-W_R}R\,-\frac{V_{\text{max}}}{1-W_R}Y' \\ &= \frac{V_{\text{max}}}{1-W_R}(1-0.299)R - \frac{V_{\text{max}}}{1-W_R}(0.587G) -\frac{V_{\text{max}}}{1-W_R}(0.114B) \end{align}$$ where once again, the expression for $Y'$ was substituted, and $\frac{V_{\text{max}}}{1-W_R}=0.877$ can be used to evaluate each component.

Finally, we can compose the three equations into a simple matrix equation, which is what you have: $$ \left[ \begin{matrix} Y'\\ U \\ V \\ \end{matrix} \right] = \left[ \begin{matrix} 0.299& 0.587 & 0.114 \\ -0.14713 & -0.28886 & 0.436 \\ 0.615 & -0.51499 & -0.10001 \\ \end{matrix} \right] \left[ \begin{matrix} R\\ G \\ B \\ \end{matrix} \right]$$

Let me know if there is any step that needs clarification.