Wednesday
Jun292011
That looks fake!
Hany Farid |
Wednesday, June 29, 2011 at 2:45PM I often receive emails from people asking me to analyze a photo that they are convinced is fake. As evidence of this fakery, they describe artifacts that appear to have been left behind from purported photo tampering. More often than not their analysis is flawed. One of the most common mistakes made is that of confusing JPEG compression artifacts with the remnants of photo tampering.
The JPEG format is what is termed a lossy compression scheme, which means that some information in the image is thrown away in order to reduce the file size of the stored image. This compression results in a loss of overall image quality and the introduction of specific artifacts that can, at times, be confused with traces of photo tampering. In order to not confuse the two, it is important to first understand how JPEG compression works.
The JPEG compression of an image typically follows six basic steps:
- 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.
This compression introduces a number of different artifacts into an image:
- 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]


Reader Comments