

And the non-zero coefficients can be rounded off ( quantized) to less than 8 bits each, depending on the compression level. But it tends to produce a lot of coefficients that are nearly zero, and can be rounded off to exactly zero without a big visual quality loss. This transformation itself isn't particularly lossy. (The 1D version of this is trying to represent a square wave as a sum of cosines - this site has a visual demo) A smooth gradient only has low frequencies, while sharp edges like text, blades of grass, and/or leaves of a shrub, have lots of high frequency components. The key building block for JPEG is a 2D DCT (Discrete Cosine Transform) (in every 8x8 block separately) that transforms the spatial pixel information into the frequency domain.

The extremes are uniform white or black (very tiny), vs. These are two different images, not of the same scene?įor the same perceptual quality, some images compress better than others.ĭoes one have a lot of smooth or blurred areas (like the sky without a lot of clouds, or only the subject in focus), while another has lots of fine detail, especially with sharp edges like grass and shrubs where the edges of every blade and leaf are visible, or a print fabric? You won't see much difference with the initial image. Set it to "Color" blend mode (so the resulting image is the color of the top layer applied to the luminosity of the bottom layer).Import the color version as a new layer.Scale it down by 2 in both directions (you can even try a factor of 4).*This works because our eyes are much more sensitive to luminosity than to color. Some applications have independent settings for quality and chroma, while others use a given subsampling depending on the quality setting. This directly results in a much smaller file size. So, when the chroma is quartered you have reduced the size of the data to a half before even applying the compression. Pixels, and with the chroma quartered your have: 1 + ¼N + ¼N = 1.5×N But with the chroma halved you have: N + ½N + ½N = 2×N So if you start with an image with N pixels, you initially have: N + N + N = 3×N The lossy compression is then applied to each plane.The next step is called "chroma sub-sampling": the two chroma planes can then be scaled down by a factor of two in one dimension (chroma halved), or by a factor of two in both dimensions (chroma quartered)*.Instead of being saved as three R, G and B planes, your image is decomposed into 3 planes, one that carries luminosity, and two that carry color (aka chroma) information.The JPEG compression algorithm works like this:
