Edit (18/01/2013)
I have edited this post on the above date. However, the only change that I have made is that I am now hosting the source code (found at the end of this post) on GitHub. This means, that if I need to make a change to the code, I do not have to edit this post again – as it will pull the latest version of it from the relevant page on GitHub whenever it is accessed by a reader.
Jargon
In case you don’t know what they mean, I’ve included the following list of jargon terms and rough descriptions of them.
RGB = Red, Green, Blue
YUV = similar to RGB, except that luma (Y) and chroma (U and V) are stored
Sources?
Most of the information for this post came from the Wikipedia article on YUV. You can visit it here: [LINK]
RGB? YUV?
Last week, a friend of mine wanted to meet in the city centre and go for a nosey around the TV stores. He’d recently bought his own place, and is decorating it and looking for a new TV.
While we were walking around “Electronics-Company-That-Isn’t-Named-After-A-Spicy-Food-At-All”, we spotted the Sony and LG LED TVs. I got to wondering whether TV transmissions are still sent in YUV, and whether those same signals were converted to RGB before being displayed on screen.
When I got home, I decided that I should look into YUV and see just how it works. I didn’t actually get around to reading about YUV until this afternoon, but when I did it made sense.
The human eye is more sensitive to changes in brightness, rather than certain colours. So, why not send the luma (brightness) information and the chroma (colour difference) information?
Back in the days of blank and white TV, all that the TV broadcasters had to send was the luma (brightness) information. As colour TV was invented, top boffins thought that the best (read: “way that requires less bandwidth over the air”) way to send the colour information was the extend the model of just sending luma information, this time including chroma information.
The best way to understand this is to see it. Luckily, Wikipedia have an amazing example. In the following picture (click to enlarge):
- The top image is how it is displayed on screen in any picture browser
- The second (blank and white) image is the luma data for the image
- The third (mostly blue and green) image is the U chroma data for the image
- The forth (mostly yellow and orange) images is the V chroma data for the image

Images via Wikipedia
They could have ditched the older system of just sending luma, and gone with a purely RGB system. However, this would have required the transmitters to send redundant, extra data over the airwaves. Plus, the older blank and white TV sets would no longer have worked. If a blank and white TV is used, then it simply ignores the UV portion of a received signal.
Also, the data being sent can be compressed before sending over the airwaves. In fact, the video portion of digital broadcasts are compressed in (almost) the same way. Because the human eye is more sensitive to changes in brightness, the chroma differences can be compressed (sampled fewer times), thus reducing the bandwidth.
Why Are You Telling Me All Of This, Jamie?
Basically, one of the ways that I can tell if I understand something that I’ve just learnt is to test myself in some way.
Ever wondered why you have exams in most of your classes?
Also, this links into my (very basic) teacher training:
- Teach something to the student(s)
- Get the student(s) to tell you what you’ve just taught them in their own words
Anyway, I’ve tested myself by taking what I’ve learnt about the RGB to YUV conversion and created a small C program that converts RGB to YUV.
At the minute it only converts a set of user inputted strings that represent the RGB values and returns their YUV equivalents.
My browsers built in spell check system is telling me that “inputted” isn’t a word. I’m sure that it is. In fact, a whole slew of Internet resources tells me that it is.
Anyway, onto the code. I wont write any more information about the code than this (as everything else should be included in the comments for my code, hopefully):
I compiled this on MS Windows 7 x64, with MiNGW’s gcc with the following options/command:
gcc <path to source file> -o RGB.exe -O2
One last thing: If you’re going to compile and run this yourself, remember to put a blank line at the end of the source code. It’s ANSI C, after all.
When I added my source code to this page, it had the blank line at the end. But when I previewed the page, the blank line was pruned from the code viewer provided by WordPress. But if you click on either “View source” or “Copy to clipboard” (when hovering over the source code black), you’ll get the code with the blank line at the end.
Until next time,
J – “Soul, peace and chicken grease” (as my brother says)