Functions > Image Processing > Image Color Tools > Example: Television Image Color Standards
  
Example: Television Image Color Standards
Use the rgb_to_yiq, rgb_to_ycbcr, yiq_to_rgb, and ycbcr_to_rgb functions to manipulate image colors.
The arguments to these functions are color matrices of one representation, and the functions return equivalent color matrices in a different representation.
Most computer-generated color images are in RGB format, where each pixel is represented by three numbers: red, green, and blue color intensities, which add together to make the color of the pixel. However, RGB is not what is used in color television. Instead, there are various color representation standards where there is a luminance or brightness value (symbol Y) that is used for black-and-white televisions, and two chrominance or color values.
The human visual system has less acuity for spatial variation of color than for brightness. Therefore, instead of using RGB, it is better to use a single channel for brightness (luma) and use two other channels for the color information. In order to compress the images we can simply down sample the color information without losing much perceptual quality. Several type of channels can be used, and some of the most common ones are YIQ and YUV where Y is the luma (or perceived luminance) and IQ and UV are the chroma channels (color/luminance information that could be downsampled). Standard video equipment uses this type of compression whether it is digital or analog.
For information on using this example, refer to About Image Processing Examples.
RGB Transformation to YIQ
In North America, the National Television System Committee (NTSC) has a standard known as YIQ, which is a linear transformation of RGB, as follows:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
You can adjust the RGB_in and YIQ_in values above and see what the equivalent YIQ and RGB output values are. Normally, you round the calculated RGB values to the nearest integer.
rgb_to_yiq and yiq_to_rgb
Use these functions to transform RGB image matrices to YIQ and vice versa.
1. Read in an RGB image.
Click to copy this expression
Click to copy this expression
(planet_ppm.bmp)
2. Convert the RGB image into YIQ and back into RGB, and then verify that the resulting image is identical to the original.
Click to copy this expression
Click to copy this expression
Click to copy this expression
(planet_yiq_rgb.bmp)
Digital Television Standard CCIR 601
The CCIR 601 standard stores images in YCbCr format. This format is a linear transformation of RGB with a more uniform output range.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
You can adjust the RGB_in and YCbCr_in values above and see what the equivalent YCbCr and RGB output values are. Normally, you round the YCbCr and RGB values to the nearest integer.
RGB values range from 0 to 255, Y values range from 16 to 235, and Cb and Cr values range from 16 to 240 (the extremes of the range are used for other purposes in the signal).
rgb_to_ycbcr and ycbcr_to_rgb
Use these functions to transform RGB image matrices to YCbCr and vice versa.
Convert the original RGB image to YCbCr and back into RGB, and then verify that the resulting image is identical to the original.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
(planet_rgb_ycbcr.bmp)
(planet_ycbcr_rgb.bmp)