## Re: [stella] tia hue luminance

 Subject: Re: [stella] tia hue luminance From: "Eric Ball" Date: Fri, 5 Dec 2003 21:37:02 -0500
```This has been bugging me for a while, but I think I have it figured out.
(This is a little long, but bear with me.)

Okay, start with the R'G'B' -> Y'U'V' formulas and derive the reverse.
Y' = 0.299R' + 0.587G' + 0.114B'
U' = 0.492(B' - Y')
V' = 0.877(R' - Y')

Getting back from Y'U'V' to red and blue is easy.
R' = 1.140V' + Y'
B' = 2.033U' + Y'

green is a little harder
Y' = 0.299(1.140V' + Y') + 0.587G' + 0.114(2.033U' + Y')
0.587G' = 0.587Y' - 0.232U' - 0.341V'
G' = Y' - 0.3947U' - 0.5808V'

Okay, now how do we get from COLU to Y'U'V'?  This is what I was struggling
with previously.  What I realized is there are two reference points which
the TV can use for automatic gain correction: the sync pulse (which signals
to the TV the start of the line) and the colorburst (which the TV uses sync
the phase of the color demodulator).

Because the VCS uses the same signal to generate both the colorburst and
color, the magnitude of both will be the same (40 IRE).  Looking at the
schematics of the VCS reveals the same resistor is used on both the sync pin
and the L2 pin.  So sync and L2 will be both the same (40 IRE again), with
the other bits being half and half again.  (Well, maybe not exactly, but
close enough.)

100% Y' is 100 IRE, so the formula for Y' is:
Y' = 0.1 * ( COLU AND 15 )

U' & V' are a little trickier.  However, some reference documents I have
give the IRE levels for 100% color bars and some calculations show that 100%
U' or V' is 190 IRE.  Thus the formulas for U' & V' are:
hue = 180 degrees - ( COLU / 16 - 1 ) * 24 degrees
saturation = 0 if ( COLU / 16 == 0 ), otherwise saturation = 40/190
U' = saturation * cos ( hue )
V' = saturation * sin ( hue )

Calculating the R'G'B' values from COLU is left as an exercise for the

Note: R'G'B' are non-linear values which should be limitted to the range
0.0 - 1.0 and represent the voltage used to drive the CRT guns.  Linear RGB
requires a gamma correction of 2.2 from R'G'B'.

I've done the calculations and done a sample picture, but I'm not sure
whether I should be using R'G'B' or RGB.

----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

```