JPEG

JPEG ( [ dʒeɪpɛɡ ] ) is the common name for the introduced in 1992 ISO / IEC 10918-1 and CCITT Recommendation T.81 describes the various methods of image compression. The term " JPEG" goes back to the Panel Joint Photographic Experts Group, which developed the JPEG standard.

JPEG proposes various compression and encoding methods, including lossy and lossless compression, different color depths, as well as sequential or progressive modes (normal image formation and gradual refinement). Widely distributed, only the lossy compression of sequential or progressive mode and 8-bit color channels.

The JPEG standard specifies only image compression method, but does not specify how the data should be stored as incurred. Commonly with " JPEG " or " JPG - files " files in graphic format JPEG File Interchange Format ( JFIF) respectively. JFIF is, however, store only one type, JPEG data; Spiff and JNG are other, albeit less common, ways.

  • 3.1 Inverse Discrete Cosine Transform
  • 3.2 Color Space Conversion

Overview and Standards

The JPEG standard ISO / IEC 10918-1 defines the following modes, of which only are colored supported use:

In addition to in ISO / IEC 10918-1 defined lossy mode, there is the improved lossless compression method JPEG -LS, which was set in a different standard. And there is the JBIG standard for compression of black and white images.

JPEG and JPEG-LS are defined in the following standards:

The JPEG standard carries the official title Information technology - Digital compression and coding of continuous- tone images quietly: Requirements and guidelines .. The " joint " in the name comes from the collaboration between ITU, IEC and ISO.

The JPEG compression

The JPEG standard defines 41 different sub-file formats, but usually only one of which is supported ( and which also covers almost all applications ).

The compression is carried out by applying a plurality of processing steps, of which four are lossy.

  • Color space conversion from (mostly) the RGB color space into YCbCr color model ( CCIR 601). (lossy )
  • Low-pass filtering and sub-sampling the color deviation signals Cb and Cr (lossy ).
  • Divided into 8 × 8 blocks and discrete cosine transform these blocks (theoretically lossless, due to rounding errors but lossy ).
  • Quantization (lossy ).
  • Reordering.
  • Entropy coding.

The data reduction is effected by the lossy processing steps in conjunction with the entropy coding.

Compressions to about 1.5-2 bits / pixel are visually lossless, at 0.7-1 bits / pixel are still good results achieved, below 0.3 bits / pixel JPEG is practically useless, the image is increasingly conspicuous compression artifacts ( block formation, stage transitions, color effects covered in gray wedges ). The successor to JPEG 2000 is much less susceptible to this type of artifacts.

One sees as the source format to 24 -bit RGB files, you get compression rates of 12 to 15, for visually lossless images and up to 35 for more good pictures. The quality depends but in addition to the compression rate is still on the nature of the images. Noise and periodic fine structures in the image to reduce the maximum possible compression rate.

The JPEG lossless mode for lossless compression uses a different method ( predictive coder and entropy coding ).

Color space conversion

The output image, which is usually present as an RGB image is converted into YCbCr color space. Basically, the YPbPr scheme is used according to the CCIR 601:

Since the R'G'B ' values ​​already in digital form as an 8- bit numbers in the range {0, 1, ..., 255 }, the YPbPr components must only move ( renormalized ), whereby the components y' ( luminance ), Cb ( color arise blueness ) and Cr (color redness ):

The components are now again in the range {0, 1, ..., 255 }.

During the conversion of the color space the usual rounding errors caused by limited computational accuracy and additional data reduction, since the Cb and Cr values ​​are only calculated for every second pixel (see CCIR 601).

Low-pass filtering of the color difference signals

The color difference signals Cb and Cr are usually stored in reduced resolution. For this they are low-pass filtered and sub-sampled (in the simplest case by averaging).

Most vertical and horizontal sub-sampling is by a factor of 2 is used (YCbCr 4:2:0 ), which reduces the data volume by a factor of 4. In this conversion, the fact is exploited that the spatial resolution of the human eye for color is significantly lower than for brightness transitions.

Block formation and discrete cosine transform

Each component (Y, Cb, and Cr ) of the image is divided into 8 × 8 blocks. These are subjected to a two-dimensional discrete cosine transform ( DCT):

With

This transformation can be implemented with very little effort using the fast Fourier transform (FFT). The DCT is an orthonormal transform, has good energy compression properties and there is an inverse transformation, which also means IDCT ( that the DCT is lossless, it went no information is lost because the data brought in only one for further processing more convenient form were ).

Quantization

As in all lossy encoding process, the actual data reduction ( and degradation ) is achieved by quantization. For this, the DCT coefficients are divided by the quantization matrix ( each element divided ) and then rounded to the nearest integer:

In this rounding step irrelevance takes place. The quantization matrix is responsible for both the quality and the compression rate. It is stored in JPEG files in the header ( DQT marker).

Optimally, the quantization matrix when it represents the sensitivity of the eye to the respective spatial frequencies in approximately. Coarse structures for the eye is more sensitive, therefore, the quantization values ​​of these frequencies are less than the high frequencies.

Here an example of a quantization matrix, and their application to an 8 × 8 block of DCT coefficients:

Reordering and differential coding of the DC component

64, the coefficients of the discrete cosine transformation are sorted by frequency. This results in a zig -zag -shaped order, starting with the DC component with the frequency 0 After Direct Current English it is abbreviated to DC, where he refers to the average brightness. The coefficients of high value are now mostly first and small coefficients later. This optimizes the input of the subsequent run-length encoding. The Umsortierreihenfolge looks like this:

1 2 6 7 15 16 28 29   3 5 8 14 17 27 30 43   4 9 13 18 26 31 42 44 10 12 19 25 32 41 45 54 11 20 24 33 40 46 53 55 21 23 34 39 47 52 56 61 22 35 38 48 51 57 60 62 36 37 49 50 58 59 63 64 Furthermore, the DC component is once more to block the left of it differentially encoded and taken into account in this way the dependencies between adjacent blocks.

The above example leads to the following coefficients rearranged

119 ...   78 3 -8 0 -4 7 0 -1 -1 0 0 0 -2 1 0 1 1 -1 0 ... 102 5 0 -5 3 -4 2 -1 0 0 0 0 1 1 -1 0 0 -1 0 0 0 0 0 0 0 1 0 ...   75 -19 2 -1 0 -1 1 -1 0 0 0 0 0 0 1 ... 132 -3 -1 -1 -1 0 0 0 -1 0 ... Coding the difference coefficients of the first results in:

3 -41 -8 -4 0 7 0 -1 -1 0 0 0 -2 1 0 1 1 -1 0 ...   24 5 0 -5 3 -4 2 -1 0 0 0 0 1 1 -1 0 0 -1 0 0 0 0 0 0 0 1 0 ... -27 -19 2 -1 0 -1 1 -1 0 0 0 0 0 0 1 ...   57 -3 -1 -1 -1 0 0 0 -1 0 ... In structurally poor regions ( the same image ), the coefficients can also look like this:

35 -2 0 0 0 1 0 ...    4 0 1 0 ...    0 0 2 0 1 0 ... -13 0 -1 ...    8 1 0 ...   -2 0 ... These areas may be naturally better than encode structurally rich areas. For example, by a run length encoding.

Although the zigzag reordering the DCT coefficients falls within the scope of U.S. Patent 4,698,672 ( and other applications and patents in Europe and Japan). However, it was found out in 2002 that the claimed method according to the prior art was not new, so the claims are hardly enforceable. Meanwhile, the patents from the patent family are off to the said U.S. patent also the passage of time, such as the EP patent 0266049 B1 in September 2007.

Entropy

As entropy coding Huffman coding is usually used. The JPEG standard also allows for an arithmetic encoding. Although these smaller 5-15 percent files generated, it is hardly used due to patent restrictions, this encoding is also much slower.

JPEG decoding

The decompression ( usually called decoding ) are the inverse of the compression:

  • Entropy decoding
  • Resorting
  • Requantization
  • Inverse Discrete Cosine Transform.
  • Oversampling and low-pass filtering of the color difference signal U and V (lossy )
  • Color space conversion from YCbCr color space to the destination color space (usually RGB)

The decompression is indeed ( mostly ) lossless, however, we have the inverse decoder problem. From the decoded data, it is difficult possible to reconstruct the original file. A decoding encoding process changed the file and is therefore not lossless, kick it on just like an analog dubbing generation loss.

The generation loss of JPEG, however, are comparatively small when again the same quantization table is used and the block boundaries are the same. With suitable boundary conditions may make you even avoid with JPEG. The JPEG -2000 which is no longer the case ( overlapping transformations as they come in JPEG -2000 as well as in audio data compression used, but require utopian computing power ).

Inverse discrete cosine transform

For DCT exists the inverse transformation, the IDCT:

With the same correction factors as in the DCT.

Color space conversion

The back-calculation from YCbCr to RGB color space via the inverse matrix of Hinrechnung, it reads:

With:

Progressive JPEG

A JPEG image consists of coefficients. This store any pixels, but approximations of the whole image content of an 8 × 8 image block. When Progressive JPEG is only the first coefficients of each image block, then the second, etc. stored sequentially, so that the approximation to the original image is always better.

As with the interlacing, which is applied to GIF, the purpose is to provide the user even before the entire file is loaded, quick to give a rough thumbnail. This is especially useful when loading an image longer than a half to full second takes or requires only a preview. However, large images are still available mostly in normal JPEG mode for download.

Lossless editing of JPEG

Although decoding and recoding is usually lossy, some image manipulations can (in principle) to perform without undesirable loss of information:

  • Image rotations of 90 °, 180 ° and 270 °
  • Horizontal and vertical reflections
  • Trimming of edges by multiples of 16 pixels (or 8 pixels in black and white images or color images without subsampling )

For this purpose, the entropy and the zig -zag reordering has to be reversed. The operations are then carried out on the basis of the DCT coefficients ( reordering, omission of unnecessary blocks). Then again take place the zig -zag reordering and the entropy coding. There will not be any lossy steps more. Not every program performs these operations by lossless, it needs to specific file format specific processing modules. The popular image editing software that is usually not the case, since this is first decode usually the file into a bitmap and then work with that data.

Jpegtran For example, the available for Windows and Linux console program can find its lossless perform all of these operations, as well as the GUI -based Irfan View for Windows.

Images whose resolution is not a multiple of 16 pixels (or 8 pixels in black and white images or color images with no sub-sampling ), are problematic. They have incomplete blocks, i.e., blocks that do not use all the synthesized pixel. JPEG allows such blocks but only at the right and bottom of the screen. Therefore, some of these operations require unique that these margins are discarded.

Visual quality and related formats

The JPEG compression has been developed for natural (raster ) images, as found in photography or computer generated images.

JPEG is not suitable for

  • Digital line drawings (eg screenshots or vector graphics ) that contain many high frequency image components ( hard edges ),
  • Black and white images with 1 bit per pixel,
  • Rasterized images ( newsprint ).

Also, you can not create transparent graphics with JPEG.

Formats such as GIF, PNG or JBIG are much better suited for these images.

Although a subsequent Increasing the quality factor increases the memory requirement of the image file, but does not return lost image information. The quantization can be chosen arbitrarily and are not standardized. Many image editing programs allow the user to select a global quality factor between 0 and 100, which is converted to a quantization according to a formula published by the JPEG committee JPEG library. Even with quality factors such as "100" or "100%" is still a quantization and thus - in JPEG images unsuitable for substantial - quality loss instead.

A JPEG transformation is not idempotent in general. The opening and subsequent saving a JPEG file results in a new lossy compression.

The sample image compares recordings that have been encoded with different quality settings. The portrait shot has a size of 200 × 200 pixels. In 24-bit color or uncompressed storage of this image produces a 120 Kbyte large file (excluding header and other meta information ). The formation of small blocks of 8 × 8 pixel squares represents the right part of image is enlarged represents a further problem in addition to the formation of small blocks is the " Ringing ", a consequence of the bad behavior of the DCT with sharp color transitions.

In the professional sector JPEG is rarely used because of the lossy data reduction. Instead formats are used, which compress losslessly, regardless of the large storage requirements. Examples are TIFF, BMP, TGA or PNG ( full-color mode ). An uncompressed recording of 6 megapixels requires at a color depth of 16 bits per color and three primary colors a memory requirement of 36 MB, which can be only a moderate decrease in structurally rich, grainy or noisy images through lossless compression (with detailed photos are compression rates of about 50 % is the norm ).

It is often possible to optimize the compression of existing JPEG files without any further losses and thus to reduce the file size slightly. Newer versions of some packers are able to compress JPEG images without any losses by up to 25%.

The moving picture compression standard MPEG -1 ( closely related to the codec Motion JPEG ) and MPEG -2 are based on the JPEG standard on. A follow-up project of JPEG for storing images is JPEG 2000, which has better compression and many useful properties, but could not prevail at least until now widely. Another potential successor format is JPEG XR, which is based on the model developed by Microsoft HD Photo format, which is, however, also been only sporadically supported.

Patent issues

Several companies have already tried to rise from their (mostly wrongly granted ) patents claims against software manufacturers whose products can read or create JPEG files. So far, all relevant patents were subsequently withdrawn. Nevertheless, the requestor could take millions of euros in extra-judicial settlements.

454800
de