JPEG Sub-sampling



Unlike must color image formats, JPEG does not store images as Red, Green, Blue (RGB), but instead as YUV (aka YCbCr), which is based on broadcast television color definitions. What sub-sampling does is spread color data across multiple pixels, either horizontally or vertically. This reduces the amount of data that has to be stored (or transmitted).


For example, a normal RGB file requires 3 bytes for each pixel, stored generally as:




However, in JPEG files, the RGB is converted to YCbCr/YUV:

- Y  encodes the luminance (brightness) of the pixel.

- U and V encode the color of the pixel.


The sub-sampling tells how many pixels will share color information.


1:1 sub-sampling doesn't really sub-sample; three bytes are stored for each pixel.


       YUV YUV YUV YUV (3 bytes per pixel, just like RGB)


For 2:1 (Horizontal/Vertical) sub-sampling, the colors of each two adjacent pixels are averaged (but the *brightness* is still stored for each pixel). Thus, the data required is less, and stored as (for four pixels).


       YYUV YYUV


So, only four bytes are required to store 2 pixels


2:2 means sub-sampling by two pixels in each direction, so only 6 bytes are required to encode 4 pixels.





The extreme case, 4:4, which ThumbsPlus doesn't write because it is more often visible, requires only 18 bytes to store 16 pixels.







Sub-sampling occurs before the actual JPEG compression, thus making the file even smaller. Sub-sampling obviously affects the color accuracy of the image; however, the effect on photographs is usually not visible to the naked eye.


The following image (zoomed) demonstrate the 8 levels of sub-sampling available in ThumbsPlus. This image is a line-drawing of only two colors. These types of files are not good candidates for JPEG compression; TIFF, GIF or PNG are much more appropriate. However, this one definitely illustrates what is going on with sub-sampling!


For photographic images (more suited for the JPEG format), there is almost no apparent quality difference between the different sub-sampling methods.


So, 1:1 does provide the most accurate color, but whether you really need to use the extra disk space or download time depends on the planned use of the JPEG file itself. For digital camera pictures, it is best to store the originals as 1:1 (the way they come in from the camera), but using 2:2 for the web or e-mail is acceptable. If you plan to do a lot of editing (especially over a period of time), try converting your images to TIFF to retain color accuracy and minimize the lossiness (JPEG artifacts) that occur with repeated edits and saves.


Overall, 2:2 (which is the default, and most common for other programs as well) should be acceptable for most cases.