Welcome, Guest. Please login or register.

Author Topic: RGB<->YUV Formulas?  (Read 3179 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline HardboyTopic starter

  • Full Member
  • ***
  • Join Date: Feb 2002
  • Posts: 248
    • Show only replies by Hardboy
RGB<->YUV Formulas?
« on: April 13, 2003, 01:58:55 PM »
Hi,

Does anyone know a set of RGB<->YUV formulas that work? I´ve found tons of them on the internet, but I haven´t found a set that gave the correct results - or just near the correct result..

Anyone?
 

Offline lorddef

  • Hero Member
  • *****
  • Join Date: Apr 2002
  • Posts: 1146
    • Show only replies by lorddef
    • http://
Re: RGB<->YUV Formulas?
« Reply #1 on: April 13, 2003, 02:13:44 PM »
Well according to my multimedia lecture notes from uni, for PAL signals:

Y = 0.30R + 0.59G + 0.11B
U = 0.493 (B - Y) = -0.15R - 0.29G + 0.44B
V = 0.877 (R - Y) = 0.62R - 0.52G - 0.1B

hope that helps.
Restraining orders are just another way of saying I love you!
 

Offline HardboyTopic starter

  • Full Member
  • ***
  • Join Date: Feb 2002
  • Posts: 248
    • Show only replies by Hardboy
Re: RGB<->YUV Formulas?
« Reply #2 on: April 13, 2003, 02:42:29 PM »
Quote
hope that helps.


Depends. Do you have the reverse formulas?
 

Offline lorddef

  • Hero Member
  • *****
  • Join Date: Apr 2002
  • Posts: 1146
    • Show only replies by lorddef
    • http://
Re: RGB<->YUV Formulas?
« Reply #3 on: April 13, 2003, 03:38:28 PM »
just do a bit of algebra to transpose them around, that'll give you the reverse formulas.
Restraining orders are just another way of saying I love you!
 

Offline HardboyTopic starter

  • Full Member
  • ***
  • Join Date: Feb 2002
  • Posts: 248
    • Show only replies by Hardboy
Re: RGB<->YUV Formulas?
« Reply #4 on: April 13, 2003, 04:06:07 PM »
I know that, but i´m too lazy...
 

Offline lorddef

  • Hero Member
  • *****
  • Join Date: Apr 2002
  • Posts: 1146
    • Show only replies by lorddef
    • http://
Re: RGB<->YUV Formulas?
« Reply #5 on: April 13, 2003, 04:20:55 PM »
it'd take all of 5 minutes
Restraining orders are just another way of saying I love you!
 

Offline iamaboringperson

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 5744
    • Show only replies by iamaboringperson
Re: RGB<->YUV Formulas?
« Reply #6 on: April 14, 2003, 05:13:11 AM »
i wish i knew how the chroma signal in pal worked....
i know about luma
i just want to know how red and blue fit in
 :-)
 

Offline tonyw

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 553
    • Show only replies by tonyw
Re: RGB<->YUV Formulas?
« Reply #7 on: April 29, 2003, 12:38:47 AM »
If there's one thing I know about, it's PAL TV theory. So, to be boring . . .

The RGB inputs from the source are combined to form a luminance signal Y=0.59*G + 0.3*R + 0.11*B. That provides a B&W signal that is important for back-compatibility. The colour signals are then added to that.

The colour signals added to the luminance signal always deteriorate the displayed luminance signal to some extent. So, it is designed that the colour signals become zero when there is no colour, ie in B&W areas, where the eye can see finest detail. To do that, we transmit colour difference signals, that are zero in B&W areas.

The colour (hue) range is arranged as a circle, with blue on the left, yellow on the right, red up the top and green at the bottom. No colour at all is the dot in the middle, full saturated colour is the point on the circle at the right angle. Any point within the circle represents less saturated (washed out) colour of that angle (hue) and radius (saturation). Such a point can be described by the radius and angle, or more conveniently, by the x and y co-ordinates, U (horizontal) and V (vertical). +V is red-magenta, -V is green (ish), +U is blue, -U is yellow (ish).

The U signal is generated by (B-Y), V by (R-Y). It's these signals that are then encoded into the chrominance signal and added to the luminance signal to make a composite signal to transmit.

To make the chroma signals
(1) easy to detect in the receiver;
(2) less likely to interfere with the luminance;
(3) independent of each other;
they are modulated onto a colour subcarrier that is high in the luminance passband (4.43 MHz). Each is modulated onto a subcarrier that is 90 degrees out of phase with the other. A synchronous detector in the receiver will not hear any of the other signal, so you have two independent channels. To reduce interference with the luminance, the two signals are transmitted with the carrier signal suppressed, so that in B&W areas, there is nothing but the B&W luminance signal.

This whole system was designed by the American National Televison System Committee (NTSC) in the 1950s. Although the details have been improved by the PAL system, the basic principles have remained. It truly is one of the great inventions of electronics.

tony
 

Offline iamaboringperson

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 5744
    • Show only replies by iamaboringperson
Re: RGB<->YUV Formulas?
« Reply #8 on: April 29, 2003, 12:44:41 AM »
WOW! thankyou! :-o  :-o  :-o

thats just ONE of lifes mistries out of the way...  ;-)
 

Offline JetRacer

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 501
    • Show only replies by JetRacer
Re: RGB<->YUV Formulas?
« Reply #9 on: April 29, 2003, 10:10:10 AM »
Unrelated, but if anyone want to convert color graphics to grey:

R 0.299
G 0.587
B 0.114

R+G+B = 1.0

I found this out when I wrote a Floyd-Steinberg dithering routine. Without evaluating the error of the color selection properly, the dithered image would become slightly green toned.

Another issue was that a 50% b/w pattern would become 70.7% grey (1/sqrt(2)), not 50% grey. So I had to correct that too. AFAIK, I'm the only one that have adressed that issue (that statement includes Photoshop, GIMP and NetPBM).
*Zap! Zap!* Ha! Take that! *Kabooom!* Hey, that\'s not fair!
 

Offline Jaruzel

  • Sr. Member
  • ****
  • Join Date: May 2002
  • Posts: 327
    • Show only replies by Jaruzel
    • http://www.Jaruzel.com
Re: RGB<->YUV Formulas?
« Reply #10 on: April 29, 2003, 10:14:08 AM »
@tonyw

Yes, wow. For once something I normally find dry and complex, easily explained!

You should put up a webpage with a few diagrams, help the world out a bit ;-)

-Jar.
Enlightened Gurus Always Meditate.
Custom MUD Server | See My A1200D(Sparc)
[A1200D(Sparc) / 68040-33Mhz]