- Each image pixel value is encoded into one component (or channel) that describes the luminance (lightness), and two channels that describe the chrominance (hue). This requires a conversion from the more typical red, green, and blue color channels that a digital camera uses to encode pixel values.
- Because our visual system is more sensitive to luminance than chrominance, the chrominance channels are scalled down in size by a factor of two to reduce file size. This is the first place in which information is lost.
- To prepare the file for compression, each channel is partitioned into 8x8 blocks of pixels.
- The pixel values in each 8x8 block are transformed using a discrete cosine transform (DCT). This step doesn’t result in any loss of information, but it makes it easier to compress the file.
- The DCT values are quantized, which means that they are all divided by a pre-specified number and rounded to the nearest integer. This is the second place in which information is lost.
- Lastly, the quantized DCT values are encoded using a lossless compression scheme to reduce the file size even further. No information is lost in this step.
- the partitioning of an image into 8x8 blocks followed by the quantization in step 5 introduces a grid like pattern along the block boundaries;
- the quantization in step 5 blurs details in the image;
- color artifacts are introduced due to the reduction in resolution of the chrominance channels in step 2 followed by the quantization in step 5;
- and, object boundaries can appear jagged.
Shown above, for example, is an image, and shown below is a magnified view with and without compression that highlight these four artifacts.
When viewed at normal magnification, a JPEG image usually looks pretty good. But when magnified, the compression artifacts become pronounced and look a little weird — you can understand why the untrained eye may mistake JPEG compression artifacts for evidence of tampering.
[Photo credit: Hany Farid]