Why the RGB to YCbCr

We saw in the earlier post, Bitmap images used the R-G-B planes directly to represent colour images. But medical research proved that the human eye has different sensitivity to colour and brightness. Thus there came about the transformation of RGB to YCbCr.

Y: Luminance; Cb: Chrominance-Blue; and Cr: Chrominance-Red are the components. Luminance is very similar to the grayscale version of the original image. Cb is strong in case of parts of the image containing the sky (blue), both Cb and Cr are weak in case of a colour like green, and Cr is strong in places of occurrence of reddish colours.

The main question that comes to mind, is why this transformation. Medical investigation of the eye has led to findings that the rods some 120 million in number, are much more sensitive than the cones which are around 6-7 million in number. The rods are not sensitive to colour, while the cones which provide much of the eye’s colour sensitivity are found to be located close to a central region called the macula.

Well, the point of all this is that, we really do not need to keep all the information that is now represented in these colour frames (Cb and Cr) and thus these are usually sub-sampled (like in JPEG compression). The formulae for converting from RGB to YCbCr are given below.

Y = (77/256)R + (150/256)G + (29/256)B
Cb = ‐(44/256)R ‐ (87/256)G + (131/256)B + 128
Cr = (131/256)R ‐ (110/256)G ‐ (21/256)B + 128

The down-sampling of chrominance is done in 2 major variants used for most of the codecs.

  • 4:4:4 – In this, there is no sub-sampling of the chroma components, and can be as well referred and used directly as a RGB image. High-end scanners / cameras / capture devices use this format to not lose any data.
  • 4:2:2 – The chroma components are horizontally sub-sampled and their resolution is halved as compared to the luminance counterpart in this scheme. High-end digital video formats and still images generally employ this scheme.
  • 4:2:0 – In this variant, the chroma components are sub-sampled by a factor of 2, both horizontally as well as vertically, thus reducing to a factor of a quarter. The standard video compression MPEG uses this scheme.

This now prepares us to face the first steps in most compression techniques, the colour space transform followed by downsampling.

Advertisements

10 thoughts on “Why the RGB to YCbCr

  1. Pingback: JPEG – Compression Method « The Technical Experience Page

  2. Pingback: Ycbcr | TagHall

  3. Fekri Abdulwahabe

    thanx, but I have a question. I was compressed the image JPRG, As is well known, I get the component Y,Cb and Cr from YCbCr image As follows:

    imageRGB = imread(‘myimage’);
    imageRGB=imresize(imageRGB, [128 128]);
    imageYCbCr = rgb2ycbcr(imageRGB);
    imageY = imageYCbCr(:,:,1);
    imageCb = imageYCbCr(:,:,2);
    imageCr = imageYCbCr(:,:,3);
    :
    Now the question is how we can make the inverse operation? That is to say, in decoding operation, how to get the imageYCbCr from their component imageY, imageCb and imageCr for recover my image after that.

    Reply
    1. Makarand Tapaswi Post author

      Hi, I’m not sure I understood what you want to do exactly, but here goes:
      1. If you want to convert YCbCr to RGB, you can use the matlab function.
      imageRGB2 = ycbcr2rgb(imageYCbCr);

      2. If you want to just get the concatenated image — imageYCbCr from the individual components, use the cat function.
      imageYCbCr2 = cat(3, imageY, imageCb, imageCr);

      Internally imread for matlab will use readjpg, which will parse the JPEG format, so you dont really get the YCbCr components. However, you can look into the byte-wise storage format, and really extract the compressed components if you like.

      Reply
  4. Shruthy

    In most of the image watermarking schemes, we convert RGB image into YCbCr. Why this coversion? and what is the advantage of this conversion?

    Reply
    1. Makarand Tapaswi Post author

      Hi, as mentioned in the post, I guess that the reason for the conversion is still the fact that the human eye is more sensitive to changes in illumination (Y component) rather than the chrominance, or colour components (Cb, Cr). Thus, during compression, it is easier to reduce the bit requirement for the colour components, and store the luminance properly. In watermarking, I would guess that you hide the watermark data in the colour components since a user will not be able to easily spot the difference. If you use the classical RGB components, all of them contribute (in varied amounts) to the illumination and each have a distinct colour. So while this is a good “additive colour” representation for displays (TVs), it’s not so nice to represent/store/transmit the image in that form. Hope this answers your question.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s