Can anyone explain how JPEG compression works?
An algorithm called “JPEG-Compression” is used by virtually every digital camera. Please explain how this mechanism operates.
The algorithm may be broken down into its constituent parts. The steps for decompression are the inverse of the ones shown here for compression. Only the most typical compression methods are shown. This is a lossy compression of 8-bit RGB data. Lossy compression is lossy because it reduces some information in the original image (in opposite to lossless compression).
Color Conversion and Subsampling
The data is then broken down into its brightness and colour components from the original RGB data. Information is translated into Yuv format. This process does not lower data size because it only alters the way in which the data is presented. Nonetheless, subsampling the colour information does not result in a considerable loss of visible picture information since the human observer is far more sensitive to the intensity information than to the colour information. And naturally, there’s a huge drop in total data.
Block-Processing and DCT
After subsampling the colour components, the resulting Yuv picture data is chopped up into 8×8 pixel squares. These pixel grids will henceforth undergo the whole algorithm. The discrete Cosine Transform is applied to each individual block (DCT). To what extent does this imply…? There is a digital value assigned to each pixel that describes the data in the spatial domain (i.e., before any transformation has taken place). Therefore, we use a list of pixel numbers and values to describe the picture data. After the transformation, the coefficient of the spatial frequencies for the vertical and horizontal directions characterises the image content. Therefore, 64-pixel values are required to be stored in the spatial domain. We need to keep track of 64 frequency coefficients in the frequency domain. At this time, there has been no decrease of data.
Quantization
The 64 coefficients are quantized to decrease the amount of storage space they require. Quantization is a process in which some information is lost while others are gained, and the amount of loss depends on the size of the quantization steps. The level of JPEG compression is often set by the user. Quantization is the stage when user input can affect the outcome (remaining image quality and file size).
Reorder and variable length encoding
More and more coefficients become zero as quantization progresses. Moreover, these zero-valued coefficients are very certainly located in the more extreme spectral regions. As a result, the values are reorganized so that the lowest spatial frequencies appear first, and the highest frequencies appear last. It’s likely that after the reordering, we’ll see a few numbers up front followed by a large number of zeros. We can simply save “10x 0” instead of “0 0 0 0 0 0 0 0 0 0 0 0.” This method also considerably decreases the amount of data.
Tool for image compression
Adobe
Tinyjpg
Conclusion
JPEG uses a block-based compression scheme. Subsampling color data, quantizing DCT coefficients, and Huffman coding are all used to reduce the data size (reorder and coding). To adjust how much data reduction impacts image quality, the user can change the (or chose presets). You can achieve high-quality compression by skipping subsampling and using a quantization matrix that results in little data loss. With a high compression level, subsampling is activated, and the quantization matrix is used to set most coefficients to 0. As a result of the decompression process, artefacts become prominent in the image.