ColorBars theory

From Avisynth wiki
Jump to: navigation, search

Description of encoded colour-bar[1] 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[2] and Rec. ITU-R BT.1927).

filter: ColorBars and ColorBarsHD

Contents

[edit] SMPTE color bars

SMPTE Color Bars-320x240.png

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

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

color RGB
75% white (0.75, 0.75, 0.75)
75% yellow (0.75, 0.75, 0)
75% cyan (0, 0.75, 0.75)
75% green (0, 0.75, 0)
75% magenta (0.75, 0, 0.75)
75% red (0.75, 0, 0)
75% blue (0, 0, 0.75)

Black and white in this colorspace are given by

color RGB
100% white (1, 1, 1)
black (0, 0, 0)


In the SMPTE color bars the top two-thirds of the image consists of seven colorbars and below them, seven shorter bars or boxes. When a television receiver or monitor is properly adjusted and set to filter out all colors except for blue, there is no visible distinction between the bars and the boxes beneath them, and you should see four solid blue bars like this:

SMPTE Color Bars-320x240-blue only.png

If the colors are mis-adjusted, you may see a visible break in the bars like this:

SMPTE Color Bars-320x240-blue only-bad.png


The bottom section contains a pattern called the Pluge[3], which is used to set up monitor black levels[4]


[edit] 100/0/75/0 bars using Rec.601 coefficients

[edit] Y,Cb,Cr [16,235]

color YCbCr hex
gray 104,128,128 b48080
75% white 180,128,128 b48080
yellow 168,44,136 a82c88
cyan 145,147,44 91932c
green 133,63,52 853f34
magenta 63,193,204 3fc1cc
red 51,109,212 336dd4
blue 28,212,120 1cd478
100% white 235,128,128 eb8080
black 16,128,128 108080

[edit] 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
gray 104,104,104 b4b4b4
75% white 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
100% white 235,235,235 ebebeb
black 16,16,16 101010

[edit] 100/0/100/0 bars using Rec.601 coefficients

[edit] 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


[edit] 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


[edit] the pluge using Rec.601 coefficients

todo: fix (see http://forum.videohelp.com/threads/377237-Purple-green-VHS?p=2435970&viewfull=1#post2435970, and check code of Colorbars again)

-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}

[edit] 100/0/75/0 bars using Rec.709 coefficients

[edit] 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


[edit] 100/0/100/0 bars using Rec.709 coefficients

[edit] 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


[edit] 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