ColorBars theory

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(todo - add picture)
(add image; formatting tweaks)
Line 1: Line 1:
 
== SMPTE color bars ==
 
== SMPTE color bars ==
  
filter: [[ColorBars]] ...
+
filter: [[ColorBars|ColorBars,ColorBarsHD]] ...
  
 
Description of encoded colour-bar signals according to the 4:2:2 level of Recommendation ITU-R BT.601 and ITU-R BT.709. Those are described in Rec. ITU-R BT.801-1) and Rec. ITU-R BT.1927).
 
Description of encoded colour-bar signals according to the 4:2:2 level of Recommendation ITU-R BT.601 and ITU-R BT.709. Those are described in Rec. ITU-R BT.801-1) and Rec. ITU-R BT.1927).
  
{| border="1"
+
[[File:SMPTE_Color_Bars-320x240.png]]
|-
+
 
| colorbars.jpg
+
The SMPTE color bars - RGB [16,235] (Rec.601 coefficients, 75% intensity)
|-
+
 
| The SMPTE color bars - RGB [16,235] (Rec.601 coefficients, 75% intensity)
+
|}
+
  
 
In the SMPTE color bars the top two-thirds of the image consists of seven colorbars. ... Rec.601 75%, later Rec.709 at 100%. Below those seven bars a combination of blue, magenta, cyan, and white boxes is given. When a television receiver is set to filter out all colors except for blue, these boxes, combined with the of color bars, are used to properly adjust the color controls. If they are properly adjusted, there is no visible distinction between the bars and the boxes, and you should see four solid blue bars. The bottom section of the test pattern is called the pluge ... is used to ...
 
In the SMPTE color bars the top two-thirds of the image consists of seven colorbars. ... Rec.601 75%, later Rec.709 at 100%. Below those seven bars a combination of blue, magenta, cyan, and white boxes is given. When a television receiver is set to filter out all colors except for blue, these boxes, combined with the of color bars, are used to properly adjust the color controls. If they are properly adjusted, there is no visible distinction between the bars and the boxes, and you should see four solid blue bars. The bottom section of the test pattern is called the pluge ... is used to ...
Line 50: Line 48:
 
| (0,0,0)
 
| (0,0,0)
 
|}
 
|}
 +
  
 
== 100/0/75/0 bars using Rec.601 coefficients ==
 
== 100/0/75/0 bars using Rec.601 coefficients ==
  
=== Y,Cb,Cr [16,235] ===
+
==== Y,Cb,Cr [16,235] ====
  
 
As an example, consider the color yellow (0.75,0.75,0) (the used color conversions can be found here: [[Color conversions]]):
 
As an example, consider the color yellow (0.75,0.75,0) (the used color conversions can be found here: [[Color conversions]]):
 
+
yellow:
yellow:
+
Y = Kr*R + Kg*G + Kb*B = 0.75*(0.299 + 0.587)*219 + 16 = 0.6645*219 + 16 = 161.53 = 162
 
+
Cb = (B-Y)/(1-Kb) = (0 - 0.6645)/(1-0.114)*112 + 128 = -0.75*112 + 128 = 44
Y = Kr*R + Kg*G + Kb*B = 0.75*(0.299 + 0.587)*219 + 16 = 0.6645*219 + 16 = 161.53 = 162
+
Cr = (R-Y)/(1-Kr) = (0.75 - 0.6645)/(1-0.299)*112 + 128 = 0.1220*112 + 128 = 141.66 = 142
 
+
Cb = (B-Y)/(1-Kb) = (0 - 0.6645)/(1-0.114)*112 + 128 = -0.75*112 + 128 = 44
+
 
+
Cr = (R-Y)/(1-Kr) = (0.75 - 0.6645)/(1-0.299)*112 + 128 = 0.1220*112 + 128 = 141.66 = 142
+
  
 
{| border="1"
 
{| border="1"
 
|-
 
|-
| color
+
! color
| YCbCr
+
! YCbCr
 +
! (hex)
 
|-
 
|-
 
| light grey
 
| light grey
| 180,128,128 (b48080)
+
| 180,128,128  
 +
| b48080
 
|-
 
|-
 
| yellow
 
| yellow
| 162,44,142 (a22c8e)
+
| 162,44,142
 +
| a22c8e
 
|-
 
|-
 
| cyan
 
| cyan
| 131,156,44 (839c2c)
+
| 131,156,44
 +
| 839c2c
 
|-
 
|-
 
| green
 
| green
| 112,72,58 (70483a)
+
| 112,72,58
 +
| 70483a
 
|-
 
|-
 
| magenta
 
| magenta
| 84,184,198 (54b8c6)
+
| 84,184,198
 +
| 54b8c6
 
|-
 
|-
 
| red
 
| red
| 65,100,212 (4164d4)
+
| 65,100,212
 +
| 4164d4
 
|-
 
|-
 
| blue
 
| blue
| 35,212,114 (23d472)
+
| 35,212,114  
 +
| 23d472
 +
|-
 +
| white
 +
| 235,128,128
 +
| eb8080
 +
|-
 +
| black
 +
| 16,128,128
 +
| 108080
 
|}
 
|}
  
white: 235,128,128 (eb8080)
 
 
black: 16,128,128 (108080)
 
 
=== R,G,B [16,235] ===
 
 
yellow:
 
 
R = 0.75*219 + 16 = 180.25 = 180
 
 
G = 0.75*219 + 16 = 180.25 = 180
 
  
B = 0*219 + 16 = 16
+
==== R,G,B [16,235] ====
 +
yellow:
 +
R = 0.75*219 + 16 = 180.25 = 180
 +
G = 0.75*219 + 16 = 180.25 = 180
 +
B = 0*219 + 16 = 16
  
 
{| border="1"
 
{| border="1"
 
|-
 
|-
| color
+
! color
| RGB
+
! RGB
 +
! (hex)
 
|-
 
|-
 
| light grey
 
| light grey
| 180,180,180 (b4b4b4)
+
| 180,180,180  
 +
| b4b4b4
 
|-
 
|-
 
| yellow
 
| yellow
| 180,180,16 (b4b410)
+
| 180,180,16  
 +
| b4b410
 
|-
 
|-
 
| cyan
 
| cyan
| 16,180,180 (10b4b4)
+
| 16,180,180  
 +
| 10b4b4
 
|-
 
|-
 
| green
 
| green
| 16,180,16 (10b410)
+
| 16,180,16  
 +
| 10b410
 
|-
 
|-
 
| magenta
 
| magenta
| 180,16,180 (b410b4)
+
| 180,16,180  
 +
| b410b4
 
|-
 
|-
 
| red
 
| red
| 180,16,16 (b41010)
+
| 180,16,16  
 +
| b41010
 
|-
 
|-
 
| blue
 
| blue
| 16,16,180 (1010b4)
+
| 16,16,180  
 +
| 1010b4
 +
|-
 +
| white
 +
| 235,235,235
 +
| ebebeb
 +
|-
 +
| black
 +
| 16,16,16
 +
| 101010
 
|}
 
|}
  
white: 235,235,235 (ebebeb)
 
 
black: 16,16,16 (101010)
 
  
 
== 100/0/100/0 bars using Rec.601 coefficients ==
 
== 100/0/100/0 bars using Rec.601 coefficients ==
  
=== Y,Cb,Cr [16,235] ===
+
==== Y,Cb,Cr [16,235] ====
  
 
{| border="1"
 
{| border="1"
 
|-
 
|-
| color
+
! color
| YCbCr
+
! YCbCr
 +
! (hex)
 
|-
 
|-
 
| light grey
 
| light grey
| 180,128,128 (b48080)
+
| 180,128,128  
 +
| b48080
 
|-
 
|-
 
| yellow
 
| yellow
| 210,16,146 (d21092)
+
| 210,16,146  
 +
| d21092
 
|-
 
|-
 
| cyan
 
| cyan
| 170,166,16 (aaa610)
+
| 170,166,16  
 +
| aaa610
 
|-
 
|-
 
| green
 
| green
| 145,54,34 (913622)
+
| 145,54,34  
 +
| 913622
 
|-
 
|-
 
| magenta
 
| magenta
| 106,202,222 (6acade)
+
| 106,202,222  
 +
| 6acade
 
|-
 
|-
 
| red
 
| red
| 81,90,240 (515af0)
+
| 81,90,240  
 +
| 515af0
 
|-
 
|-
 
| blue
 
| blue
| 41,240,110 (29f06e)
+
| 41,240,110  
 +
| 29f06e
 +
|-
 +
| white
 +
| 235,128,128
 +
| eb8080
 +
|-
 +
| black
 +
| 16,128,128
 +
| 108080
 
|}
 
|}
  
white: 235,128,128 (eb8080)
 
  
black: 16,128,128 (108080)
+
==== R,G,B [16,235] ====
 
+
=== R,G,B [16,235] ===
+
  
 
{| border="1"
 
{| border="1"
 
|-
 
|-
| color
+
! color
| RGB
+
! RGB
 +
! (hex)
 
|-
 
|-
 
| light grey
 
| light grey
| 235,235,235 (ebebeb) (white !!!)
+
| 178,178,178
 +
| b2b2b2
 
|-
 
|-
 
| yellow
 
| yellow
| 235,235,16 (ebeb10)
+
| 235,235,16  
 +
| ebeb10
 
|-
 
|-
 
| cyan
 
| cyan
| 16,235,235 (10ebeb)
+
| 16,235,235  
 +
| 10ebeb
 
|-
 
|-
 
| green
 
| green
| 16,235,16 (10eb10)
+
| 16,235,16  
 +
| 10eb10
 
|-
 
|-
 
| magenta
 
| magenta
| 235,16,235 (eb10eb)
+
| 235,16,235  
 +
| eb10eb
 
|-
 
|-
 
| red
 
| red
| 235,16,16 (eb1010)
+
| 235,16,16  
 +
| eb1010
 
|-
 
|-
 
| blue
 
| blue
| 16,16,235 (1010eb)
+
| 16,16,235  
 +
| 1010eb
 +
|-
 +
| white
 +
| 235,235,235
 +
| ebebeb
 +
|-
 +
| black
 +
| 16,16,16
 +
| 101010
 
|}
 
|}
  
white: 235,235,235 (ebebeb)
 
  
black: 16,16,16 (101010)
+
==== the pluge using Rec.601 coefficients ====
 
+
== the pluge using Rec.601 coefficients ==
+
  
 
-4/0/4 IRE levels: ...
 
-4/0/4 IRE levels: ...
Line 211: Line 254:
 
+Q/-I levels:
 
+Q/-I levels:
  
100% * 20IRE / 92.5IRE = 21.6216% = 0.2162 (include reference to 20IRE ...)
+
100% * 20IRE / 92.5IRE = 21.6216% = 0.2162  
 +
(include reference to 20IRE ...)
  
 
The components iq can be obtained by rotating vu 33 degrees poyton - eq.33 (Poyton wrong; det!=1, or am I too drunk?), that is
 
The components iq can be obtained by rotating vu 33 degrees poyton - eq.33 (Poyton wrong; det!=1, or am I too drunk?), that is
 
+
Q = V*cos(Pi*33/180) + U*sin(Pi*33/180)
Q = V*cos(Pi*33/180) + U*sin(Pi*33/180)
+
I = - V*sin(Pi*33/180) + U*cos(Pi*33/180)
 
+
I = - V*sin(Pi*33/180) + U*cos(Pi*33/180)
+
  
 
and thus
 
and thus
 
+
V = Q*cos(Pi*33/180) - I*sin(Pi*33/180)
V = Q*cos(Pi*33/180) - I*sin(Pi*33/180)
+
U = Q*sin(Pi*33/180) + I*cos(Pi*33/180)
 
+
U = Q*sin(Pi*33/180) + I*cos(Pi*33/180)
+
  
 
The components vu can be obtained from B-Y and R-Y in the following way poyton - eq.33:
 
The components vu can be obtained from B-Y and R-Y in the following way poyton - eq.33:
 +
V = 0.492*(B-Y_601)
 +
U = 0.877*(R-Y_601)
 +
+Q: Q=0.2162, I=0, Y=0
  
V = 0.492*(B-Y_601)
+
0.492*(B-Y_601) = Q*cos(Pi*33/180) - I*sin(Pi*33/180) = 0.2162*cos(Pi*33/180) = 0.1813
 +
0.877*(R-Y_601) = Q*sin(Pi*33/180) + I*cos(Pi*33/180) = 0.2162*sin(Pi*33/180) = 0.1178
  
U = 0.877*(R-Y_601)
+
Y_601 = 0
 +
R-Y_601 = 0.1178/0.877 = 0.1343 => R = 0.1343
 +
B-Y_601 = 0.1813/0.492 = 0.3685 => B = 0.3685
  
+Q: Q=0.2162, I=0, Y=0
+
G = (Y_601 - Kr*R - Kb*B)/Kg = (0 - 0.299*0.1343 - 0.114*0.3685)/0.587 = -0.1400
 +
Cb_601 = (B - Y_601)/(1-Kb) = 0.4159
 +
Cr_601 = (R - Y_601)/(1-Kr) = 0.1742
  
0.492*(B-Y_601) = Q*cos(Pi*33/180) - I*sin(Pi*33/180) = 0.2162*cos(Pi*33/180) = 0.1813
+
thus for ycbcr [16,235]:
 +
y = 16,
 +
cb = 112*0.4159+128 = 175,
 +
cr = 112*0.1742+128 = 148
  
0.877*(R-Y_601) = Q*sin(Pi*33/180) + I*cos(Pi*33/180) = 0.2162*sin(Pi*33/180) = 0.1178
+
and for rgb [16,235]:
 +
r = 219*0.1343+16 = 45,
 +
g = 219*(-0.1400)+16 = -15,
 +
b = 219*0.3685+16 = 97
  
Y_601 = 0
+
-I: q=0, i=-0.2162, Y=0  
  
R-Y_601 = 0.1178/0.877 = 0.1343 => R = 0.1343
+
0.492*(B-Y_601) = Q*cos(Pi*33/180) - I*sin(Pi*33/180) = 0.2162*sin(Pi*33/180) = 0.1178
 +
0.877*(R-Y_601) = Q*sin(Pi*33/180) + I*cos(Pi*33/180) = -0.2162*cos(Pi*33/180) = -0.1813
  
B-Y_601 = 0.1813/0.492 = 0.3685 => B = 0.3685
+
Y_601 = 0
 
+
R-Y_601 = -0.1813/0.877 = -0.2067 => R = -0.2067
G = (Y_601 - Kr*R - Kb*B)/Kg = (0 - 0.299*0.1343 - 0.114*0.3685)/0.587 = -0.1400
+
B-Y_601 = 0.1178/0.492 = 0.2394 => B = 0.2394
 
+
Cb_601 = (B - Y_601)/(1-Kb) = 0.4159
+
G = (Y_601 - Kr*R - Kb*B)/Kg = (0 - 0.299*(-0.2067) - 0.114*0.2394)/0.587 = 0.0588
 
+
Cb_601 = (B - Y_601)/(1-Kb) = 0.2701
Cr_601 = (R - Y_601)/(1-Kr) = 0.1742
+
Cr_601 = (R - Y_601)/(1-Kr) = -0.2949
 
+
thus for ycbcr [16,235]: y = 16, cb = 112*0.4159+128 = 175, cr = 112*0.1742+128 = 148
+
thus for ycbcr [16,235]:  
 
+
y = 16,  
and for rgb [16,235]: r = 219*0.1343+16 = 45, g = 219*(-0.1400)+16 = -15, b = 219*0.3685+16 = 97
+
cb = 112*0.2701+128 = 158,  
 
+
cr = 112*(-0.2949)+128 = 95
-I: q=0, i=-0.2162, Y=0
+
 
+
and for rgb [16,235]:  
0.492*(B-Y_601) = Q*cos(Pi*33/180) - I*sin(Pi*33/180) = 0.2162*sin(Pi*33/180) = 0.1178
+
r = 219*(-0.2067)+16 = -29,  
 
+
g = 219*0.0588+16 = 29,  
0.877*(R-Y_601) = Q*sin(Pi*33/180) + I*cos(Pi*33/180) = -0.2162*cos(Pi*33/180) = -0.1813
+
b = 219*0.2394+16 = 68
 
+
Y_601 = 0
+
 
+
R-Y_601 = -0.1813/0.877 = -0.2067 => R = -0.2067
+
 
+
B-Y_601 = 0.1178/0.492 = 0.2394 => B = 0.2394
+
 
+
G = (Y_601 - Kr*R - Kb*B)/Kg = (0 - 0.299*(-0.2067) - 0.114*0.2394)/0.587 = 0.0588
+
 
+
Cb_601 = (B - Y_601)/(1-Kb) = 0.2701
+
 
+
Cr_601 = (R - Y_601)/(1-Kr) = -0.2949
+
 
+
thus for ycbcr [16,235]: y = 16, cb = 112*0.2701+128 = 158, cr = 112*(-0.2949)+128 = 95
+
 
+
and for rgb [16,235]: r = 219*(-0.2067)+16 = -29, g = 219*0.0588+16 = 29, b = 219*0.2394+16 = 68
+
  
 
While ycbcr is a valid color, the corresponding rgb value is not, since r is negative. Instead of rounding it to zero, the luminance is highered to make red zero (this is done in in AviSynth v2.57). As a consequence the green for the +Q signal is also positive. This way the phase of the YIQ signal is preserved. r is zero for R = -16/219 = -0.0731, and thus Y_601 = -0.0731+0.2067 = 0.1336. It follow that:
 
While ycbcr is a valid color, the corresponding rgb value is not, since r is negative. Instead of rounding it to zero, the luminance is highered to make red zero (this is done in in AviSynth v2.57). As a consequence the green for the +Q signal is also positive. This way the phase of the YIQ signal is preserved. r is zero for R = -16/219 = -0.0731, and thus Y_601 = -0.0731+0.2067 = 0.1336. It follow that:
 +
+Q: Q=0.2162, I=0, Y=0.1336
  
+Q: Q=0.2162, I=0, Y=0.1336
+
R = 0.1343 + 0.1336 = 0.2679
 
+
B = 0.3685 + 0.1336 = 0.5021
R = 0.1343 + 0.1336 = 0.2679
+
G = -0.1400 + 0.1336 = -0.0064
 
+
B = 0.3685 + 0.1336 = 0.5021
+
and thus for rgb [16,235]:
 
+
r = 219*0.2679+16 = 75,  
G = -0.1400 + 0.1336 = -0.0064
+
b = 219*0.5021+16 = 126,  
 
+
g = 219*(-0.0064)+16 = 15
and thus for rgb [16,235]: r = 219*0.2679+16 = 75, b = 219*0.5021+16 = 126, g = 219*(-0.0064)+16 = 15
+
 
+
-I: Q=0, I=-0.2162, Y=0.1336
+
 
+
R = -0.2067 + 0.1336 = -0.0731
+
 
+
B = 0.2394 + 0.1336 = 0.3730
+
  
G = 0.0588 + 0.1336 = 0.1924
+
-I: Q=0, I=-0.2162, Y=0.1336
  
and thus for rgb [16,235]: r = 219*(-0.0731)+16 = 0, b = 219*0.3730+16 = 98, g = 219*0.1924+16 = 58
+
R = -0.2067 + 0.1336 = -0.0731
 +
B = 0.2394 + 0.1336 = 0.3730
 +
G = 0.0588 + 0.1336 = 0.1924
 +
 +
and thus for rgb [16,235]:  
 +
r = 219*(-0.0731)+16 = 0,  
 +
b = 219*0.3730+16 = 98,  
 +
g = 219*0.1924+16 = 58
  
 
..........................
 
..........................
 
 
ycbcr the same?
 
ycbcr the same?
 
 
..........................
 
..........................
  
+Q = ycbcr{16, 175, 148} = hex ycbcr{10, AD, 94}
+
+Q = ycbcr{16, 175, 148} = hex ycbcr{10, AD, 94}
 +
-I = ycbcr{16, 158, 95} = hex ycbcr{10, 9E, 5F}
  
-I = ycbcr{16, 158, 95} = hex ycbcr{10, 9E, 5F}
+
+Q = rgb{75, 15, 126} = hex rgb{4B, 0F, 7E}
 +
-I = rgb{0, 58, 98} = hex rgb{0, 3A, 62}
  
+Q = rgb{75, 15, 126} = hex rgb{4B, 0F, 7E}
 
 
-I = rgb{0, 58, 98} = hex rgb{0, 3A, 62}
 
  
 
== 100/0/75/0 bars using Rec.709 coefficients ==
 
== 100/0/75/0 bars using Rec.709 coefficients ==
  
=== Y,Cb,Cr [16,235] ===
+
==== Y,Cb,Cr [16,235] ====
  
 
{| border="1"
 
{| border="1"
 
|-
 
|-
| color
+
! color
| YCbCr
+
! YCbCr
 +
! (hex)
 
|-
 
|-
 
| light grey
 
| light grey
| 180,128,128 (b48080)
+
| 180,128,128  
 +
| b48080
 
|-
 
|-
 
| yellow
 
| yellow
| 168,44,136 (a82c88)
+
| 168,44,136  
 +
| a82c88
 
|-
 
|-
 
| cyan
 
| cyan
| 145,147,44 (91932c)
+
| 145,147,44  
 +
| 91932c
 
|-
 
|-
 
| green
 
| green
| 134,63,52 (863f34)
+
| 134,63,52  
 +
| 863f34
 
|-
 
|-
 
| magenta
 
| magenta
| 63,193,204 (3fc1cc)
+
| 63,193,204  
 +
| 3fc1cc
 
|-
 
|-
 
| red
 
| red
| 51,109,212 (336dd4)
+
| 51,109,212  
 +
| 336dd4
 
|-
 
|-
 
| blue
 
| blue
| 28,212,120 (1cd478)
+
| 28,212,120  
 +
| 1cd478
 +
|-
 +
| white
 +
| 235,128,128
 +
| eb8080
 +
|-
 +
| black
 +
| 16,128,128
 +
| 108080
 
|}
 
|}
  
white (1,1,1): 235,128,128 (eb8080)
 
 
black (0,0,0): 16,128,128 (108080)
 
  
 
== 100/0/100/0 bars using Rec.709 coefficients ==
 
== 100/0/100/0 bars using Rec.709 coefficients ==
  
=== Y,Cb,Cr [16,235] ===
+
==== Y,Cb,Cr [16,235] ====
  
 
{| border="1"
 
{| border="1"
 
|-
 
|-
| color
+
! color
| YCbCr
+
! YCbCr
 +
! (hex)
 
|-
 
|-
 
| light grey
 
| light grey
| 180,128,128 (b48080)
+
| 180,128,128  
 +
| b48080
 
|-
 
|-
 
| yellow
 
| yellow
| 219,16,138 (db108a)
+
| 219,16,138  
 +
| db108a
 
|-
 
|-
 
| cyan
 
| cyan
| 188,154,16 (bc9a10)
+
| 188,154,16  
 +
| bc9a10
 
|-
 
|-
 
| green
 
| green
| 173,42,26 (ad1a2a)
+
| 173,42,26  
 +
| ad1a2a
 
|-
 
|-
 
| magenta
 
| magenta
| 78,214,230 (4ed6e6)
+
| 78,214,230  
 +
| 4ed6e6
 
|-
 
|-
 
| red
 
| red
| 63,102,240 (3f66f0)
+
| 63,102,240  
 +
| 3f66f0
 
|-
 
|-
 
| blue
 
| blue
| 32,240,118 (20f076)
+
| 32,240,118  
 +
| 20f076
 +
|-
 +
| white
 +
| 235,128,128
 +
| eb8080
 +
|-
 +
| black
 +
| 16,128,128
 +
| 108080
 
|}
 
|}
  
white: 235,128,128 (eb8080)
 
 
black: 16,128,128 (108080)
 
 
== the pluge using Rec.709 coefficients ==
 
 
-4,0,+4 IRE: same as 1c.
 
 
+Q: q=0.2162, i=0, y=0 -I: q=0, i=-0.2162, y=0
 
 
+Q = ycbcr{16, 172.4, 145.7} = hex ycbcr{10, AC, 92} -I = ycbcr{16, 156.8, 98.6} = hex ycbcr{10, 9D, 63}
 
  
+Q: q=0.2162, i=0, y=0.134 (makes red zero for -I) -I: q=0, i=-0.2162, y=0.134 (makes red zero for -I)
+
==== the pluge using Rec.709 coefficients ====
  
+Q = rgb{74.8, 17.2, 125.9} = hex rgb{4B, 11, 7E} -I = rgb{0, 53.5, 97.6} = hex rgb{0, 36, 62}
+
-4,0,+4 IRE: same as 1c.
 +
 +
+Q: q=0.2162, i=0, y=0 -I: q=0, i=-0.2162, y=0
 +
 +
+Q = ycbcr{16, 172.4, 145.7} = hex ycbcr{10, AC, 92} -I = ycbcr{16, 156.8, 98.6} = hex ycbcr{10, 9D, 63}
 +
 +
+Q: q=0.2162, i=0, y=0.134 (makes red zero for -I) -I: q=0, i=-0.2162, y=0.134 (makes red zero for -I)
 +
 +
+Q = rgb{74.8, 17.2, 125.9} = hex rgb{4B, 11, 7E} -I = rgb{0, 53.5, 97.6} = hex rgb{0, 36, 62}
  
  
Line 400: Line 463:
 
It says that YUV is derived (defined is a better word) from Y_601,B-Y_601,R-Y_601. So, it's not derived from Y_709. To compute the corresponding YCbCr for Rec.709 one should do the following:
 
It says that YUV is derived (defined is a better word) from Y_601,B-Y_601,R-Y_601. So, it's not derived from Y_709. To compute the corresponding YCbCr for Rec.709 one should do the following:
  
YUV->RGB->YCbCr (Rec.709)
+
YUV->RGB->YCbCr (Rec.709)
  
 
But i guess that's only possible after "correcting RGB (raising luma with 13.4%)". The uncorrected (negative) RGB values are used to do this.
 
But i guess that's only possible after "correcting RGB (raising luma with 13.4%)". The uncorrected (negative) RGB values are used to do this.

Revision as of 03:20, 12 April 2015

Contents

SMPTE color bars

filter: ColorBars,ColorBarsHD ...

Description of encoded colour-bar signals according to the 4:2:2 level of Recommendation ITU-R BT.601 and ITU-R BT.709. Those are described in Rec. ITU-R BT.801-1) and Rec. ITU-R BT.1927).

SMPTE Color Bars-320x240.png

The SMPTE color bars - RGB [16,235] (Rec.601 coefficients, 75% intensity)


In the SMPTE color bars the top two-thirds of the image consists of seven colorbars. ... Rec.601 75%, later Rec.709 at 100%. Below those seven bars a combination of blue, magenta, cyan, and white boxes is given. When a television receiver is set to filter out all colors except for blue, these boxes, combined with the of color bars, are used to properly adjust the color controls. If they are properly adjusted, there is no visible distinction between the bars and the boxes, and you should see four solid blue bars. The bottom section of the test pattern is called the pluge ... is used to ...

From left to right, the colorbars consists of the following colors (given in normalized colorspace rgb [0,1]):

light grey (0.75,0.75,0.75)
yellow (1,1,0)
cyan (0,1,1)
green (0,1,0)
magenta (1,0,1)
red (1,0,0)
blue (0,0,1)

black and white are given by

white (1,1,1)
black (0,0,0)


100/0/75/0 bars using Rec.601 coefficients

Y,Cb,Cr [16,235]

As an example, consider the color yellow (0.75,0.75,0) (the used color conversions can be found here: Color conversions):

yellow:
Y = Kr*R + Kg*G + Kb*B = 0.75*(0.299 + 0.587)*219 + 16 = 0.6645*219 + 16 = 161.53 = 162
Cb = (B-Y)/(1-Kb) = (0 - 0.6645)/(1-0.114)*112 + 128 = -0.75*112 + 128 = 44
Cr = (R-Y)/(1-Kr) = (0.75 - 0.6645)/(1-0.299)*112 + 128 = 0.1220*112 + 128 = 141.66 = 142
color YCbCr (hex)
light grey 180,128,128 b48080
yellow 162,44,142 a22c8e
cyan 131,156,44 839c2c
green 112,72,58 70483a
magenta 84,184,198 54b8c6
red 65,100,212 4164d4
blue 35,212,114 23d472
white 235,128,128 eb8080
black 16,128,128 108080


R,G,B [16,235]

yellow: 
R = 0.75*219 + 16 = 180.25 = 180
G = 0.75*219 + 16 = 180.25 = 180
B = 0*219 + 16 = 16
color RGB (hex)
light grey 180,180,180 b4b4b4
yellow 180,180,16 b4b410
cyan 16,180,180 10b4b4
green 16,180,16 10b410
magenta 180,16,180 b410b4
red 180,16,16 b41010
blue 16,16,180 1010b4
white 235,235,235 ebebeb
black 16,16,16 101010


100/0/100/0 bars using Rec.601 coefficients

Y,Cb,Cr [16,235]

color YCbCr (hex)
light grey 180,128,128 b48080
yellow 210,16,146 d21092
cyan 170,166,16 aaa610
green 145,54,34 913622
magenta 106,202,222 6acade
red 81,90,240 515af0
blue 41,240,110 29f06e
white 235,128,128 eb8080
black 16,128,128 108080


R,G,B [16,235]

color RGB (hex)
light grey 178,178,178 b2b2b2
yellow 235,235,16 ebeb10
cyan 16,235,235 10ebeb
green 16,235,16 10eb10
magenta 235,16,235 eb10eb
red 235,16,16 eb1010
blue 16,16,235 1010eb
white 235,235,235 ebebeb
black 16,16,16 101010


the pluge using Rec.601 coefficients

-4/0/4 IRE levels: ...

+Q/-I levels:

100% * 20IRE / 92.5IRE = 21.6216% = 0.2162 

(include reference to 20IRE ...)

The components iq can be obtained by rotating vu 33 degrees poyton - eq.33 (Poyton wrong; det!=1, or am I too drunk?), that is

Q = V*cos(Pi*33/180) + U*sin(Pi*33/180)
I = - V*sin(Pi*33/180) + U*cos(Pi*33/180)

and thus

V = Q*cos(Pi*33/180) - I*sin(Pi*33/180)
U = Q*sin(Pi*33/180) + I*cos(Pi*33/180)

The components vu can be obtained from B-Y and R-Y in the following way poyton - eq.33:

V = 0.492*(B-Y_601)
U = 0.877*(R-Y_601)
+Q: Q=0.2162, I=0, Y=0
0.492*(B-Y_601) = Q*cos(Pi*33/180) - I*sin(Pi*33/180) = 0.2162*cos(Pi*33/180) = 0.1813
0.877*(R-Y_601) = Q*sin(Pi*33/180) + I*cos(Pi*33/180) = 0.2162*sin(Pi*33/180) = 0.1178
Y_601 = 0
R-Y_601 = 0.1178/0.877 = 0.1343 => R = 0.1343
B-Y_601 = 0.1813/0.492 = 0.3685 => B = 0.3685
G = (Y_601 - Kr*R - Kb*B)/Kg = (0 - 0.299*0.1343 - 0.114*0.3685)/0.587 = -0.1400
Cb_601 = (B - Y_601)/(1-Kb) = 0.4159
Cr_601 = (R - Y_601)/(1-Kr) = 0.1742

thus for ycbcr [16,235]:

y = 16, 
cb = 112*0.4159+128 = 175, 
cr = 112*0.1742+128 = 148

and for rgb [16,235]:

r = 219*0.1343+16 = 45, 
g = 219*(-0.1400)+16 = -15, 
b = 219*0.3685+16 = 97
-I: q=0, i=-0.2162, Y=0 
0.492*(B-Y_601) = Q*cos(Pi*33/180) - I*sin(Pi*33/180) = 0.2162*sin(Pi*33/180) = 0.1178
0.877*(R-Y_601) = Q*sin(Pi*33/180) + I*cos(Pi*33/180) = -0.2162*cos(Pi*33/180) = -0.1813
Y_601 = 0
R-Y_601 = -0.1813/0.877 = -0.2067 => R = -0.2067
B-Y_601 = 0.1178/0.492 = 0.2394 => B = 0.2394

G = (Y_601 - Kr*R - Kb*B)/Kg = (0 - 0.299*(-0.2067) - 0.114*0.2394)/0.587 = 0.0588
Cb_601 = (B - Y_601)/(1-Kb) = 0.2701
Cr_601 = (R - Y_601)/(1-Kr) = -0.2949

thus for ycbcr [16,235]:

y = 16, 
cb = 112*0.2701+128 = 158, 
cr = 112*(-0.2949)+128 = 95

and for rgb [16,235]:

r = 219*(-0.2067)+16 = -29, 
g = 219*0.0588+16 = 29, 
b = 219*0.2394+16 = 68

While ycbcr is a valid color, the corresponding rgb value is not, since r is negative. Instead of rounding it to zero, the luminance is highered to make red zero (this is done in in AviSynth v2.57). As a consequence the green for the +Q signal is also positive. This way the phase of the YIQ signal is preserved. r is zero for R = -16/219 = -0.0731, and thus Y_601 = -0.0731+0.2067 = 0.1336. It follow that:

+Q: Q=0.2162, I=0, Y=0.1336
R = 0.1343 + 0.1336 = 0.2679
B = 0.3685 + 0.1336 = 0.5021
G = -0.1400 + 0.1336 = -0.0064

and thus for rgb [16,235]:

r = 219*0.2679+16 = 75, 
b = 219*0.5021+16 = 126, 
g = 219*(-0.0064)+16 = 15
-I: Q=0, I=-0.2162, Y=0.1336
R = -0.2067 + 0.1336 = -0.0731
B = 0.2394 + 0.1336 = 0.3730
G = 0.0588 + 0.1336 = 0.1924

and thus for rgb [16,235]:

r = 219*(-0.0731)+16 = 0, 
b = 219*0.3730+16 = 98, 
g = 219*0.1924+16 = 58

.......................... ycbcr the same? ..........................

+Q = ycbcr{16, 175, 148} = hex ycbcr{10, AD, 94}
-I = ycbcr{16, 158, 95} = hex ycbcr{10, 9E, 5F}
+Q = rgb{75, 15, 126} = hex rgb{4B, 0F, 7E}
-I = rgb{0, 58, 98} = hex rgb{0, 3A, 62}


100/0/75/0 bars using Rec.709 coefficients

Y,Cb,Cr [16,235]

color YCbCr (hex)
light grey 180,128,128 b48080
yellow 168,44,136 a82c88
cyan 145,147,44 91932c
green 134,63,52 863f34
magenta 63,193,204 3fc1cc
red 51,109,212 336dd4
blue 28,212,120 1cd478
white 235,128,128 eb8080
black 16,128,128 108080


100/0/100/0 bars using Rec.709 coefficients

Y,Cb,Cr [16,235]

color YCbCr (hex)
light grey 180,128,128 b48080
yellow 219,16,138 db108a
cyan 188,154,16 bc9a10
green 173,42,26 ad1a2a
magenta 78,214,230 4ed6e6
red 63,102,240 3f66f0
blue 32,240,118 20f076
white 235,128,128 eb8080
black 16,128,128 108080


the pluge using Rec.709 coefficients

-4,0,+4 IRE: same as 1c.

+Q: q=0.2162, i=0, y=0 -I: q=0, i=-0.2162, y=0

+Q = ycbcr{16, 172.4, 145.7} = hex ycbcr{10, AC, 92} -I = ycbcr{16, 156.8, 98.6} = hex ycbcr{10, 9D, 63}

+Q: q=0.2162, i=0, y=0.134 (makes red zero for -I) -I: q=0, i=-0.2162, y=0.134 (makes red zero for -I)

+Q = rgb{74.8, 17.2, 125.9} = hex rgb{4B, 11, 7E} -I = rgb{0, 53.5, 97.6} = hex rgb{0, 36, 62}


Looking at Poynton again:

http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html

It says that YUV is derived (defined is a better word) from Y_601,B-Y_601,R-Y_601. So, it's not derived from Y_709. To compute the corresponding YCbCr for Rec.709 one should do the following:

YUV->RGB->YCbCr (Rec.709)

But i guess that's only possible after "correcting RGB (raising luma with 13.4%)". The uncorrected (negative) RGB values are used to do this.

References:

Personal tools