Lossy compression reduces the amount of data required to store a file. However, lossy compression also results in some loss of quality. JPEG images and MP3 sound files both make use of lossy compression. Despite a loss in quality, users are often unable to determine any major difference.
When an image is captured using a digital camera, it will be compressed and saved as a JPEG. Compressing images as JPEGs can reduce file size by more than 80 per cent, with little noticeable change visible to humans. Similarly, a compressed MP3 file may be one tenth the size of the original audio file and may sound almost identical.
Most lossy compression algorithms allow for various quality settings, which determine how much compression is applied to the file. The quality setting involves a trade-off between quality and file size. A file that uses greater compression will take up less space, but may not look or sound as good as a file with less compression applied.
It is important to know the following lossy compression techniques.
Perceptual coding is a lossy compression technique that is applied to sound. MP3 sound files make use of perceptual coding. Algorithms are used to remove some data from sound files. The algorithms focus on:
Discrete Cosine Transform is a lossy compression technique that is applied to JPEG images. DCT encoding is a very difficult method to understand as it involves lots of mathematical complexity. It can be summarised as:
For each of the Y, Cb and Cr images the following steps are necessary:
This happens for each of the Y, Cb and Cr images before they are combined and stored as a JPEG image. It is often the case that the data that has been removed will go unnoticed by users unless they apply a very high compression ratio at the time of DCT encoding.
MPEG video files often make use of intraframe and interframe compression. Intraframe compression is simply the process of compressing each individual image (frame) in the video. In the case of MPEG videos, each individual JPEG frame is compressed using DCT encoding as described above. These frames are then known as i-frames.
Interframe compression is the process of only saving changes between i-frames. This is achieved by using p-frames and b-frames. A p-frame only stores the changes that exist between the previous i-frame and the current i-frame. It does this by disregarding any data that has not changed. A b-frame attempts to achieve greater compression by storing changes from both the previous and next i-frames, again by disregarding any data that does not change, either from the previous frame or in the next frame.