About the Image Storage format (Introduction to the JPEG format) _ Related skills

Source: Internet
Author: User
Tags data structures

Jpg

The JPG full name is JPEG. A JPEG picture stores a single raster image in 24-bit color. JPEG is a platform-independent format that supports the highest level of compression, although this compression is lossy. An asymptotic JPEG file supports interleaving.

JPG function 

You can increase or decrease the level of JPEG file compression. However, the file size is at the expense of image quality. The compression ratio can be as high as 100:1. (The JPEG format can easily compress files at 10:1 to 20:1, and image quality will not fall.) JPEG compression is a good way to handle realistic photography. However, JPEG compression does not provide ideal results for simpler works with fewer colors, strong contrast levels, solid borders, or large areas of solid color. Sometimes the compression ratio can be as low as 5:1, which seriously loses the picture integrity. This loss is due to the fact that JPEG compression schemes can compress similar tones well, but JPEG compression schemes do not deal well with strong brightness differences or handle solid color areas.

JPG pros and cons

  Advantages : Photographic works or realistic works support advanced compression.

The file size can be controlled using a variable compression ratio.
Supports interleaving (for asymptotic JPEG files).
Broad support for Internet standards.
Because of its small size, JPG is used to store and transmit photos in the World Wide Web.

  disadvantage : lossy compression can degrade the quality of the original image data.

When you edit and save a JPEG file, JPEG blends the quality of the original picture data down. This decline is cumulative.
JPEG does not apply to simpler pictures with very little color, large areas of similar color, or sharp differences in brightness. JPG Use range
JPG format is a picture format, is a more common picture format, if your picture is another format, you can use the following methods to transform:
1, Photoshop, open the picture, press Save As, the following format where the choice of JPG format is, this method is relatively simple, but also suitable for the quality of the better, requiring a relatively high picture conversion.
2, if you are not high, you directly through the drawing program with Windows, select the JPG format can be, this conversion mode is not high quality
If the JPG format is transferred to another format, the same method applies.

JPG compression mode

JPEG (Joint Photographic Experts Group) is an international organization of international Standards (iso:international Standardization Organization) and an advisory Committee on Telephone and Telegraph (CCITT: Consultation Commitee of the International Telephone and Telegraph) is the first international digital Image compression standard established for static images, and is the most widely used image compression standard yet. Because JPEG can provide lossy compression, the compression ratio can reach the level unmatched by other traditional compression algorithms.
JPEG compression modes are available in the following ways:
Sequential encoding (sequential Encoding)
Process the image one at a time from left to right, from top to bottom.
Incremental encoding (Progressive Encoding)
When the image is transmitted for a long time, the image can be processed several times to transfer the image from Blur to clearness (the effect is similar to that of GIF transmission on the network).
Non-distortion encoding (lossless Encoding)
Step-coded (hierarchical Encoding)
Images are compressed at several resolutions to allow high-resolution images to be displayed on lower-resolution devices.

JPG compression steps

Because JPEG lossless compression is not superior to other compression methods, we focus on its lossy compression. Take a 24-bit color image as an example, JPEG compression steps are divided into:

1. Color conversion

Because JPEG supports only the YUV color mode data structure and does not support RGB image data structures, you must first convert the color pattern to data before compressing the color image. The conversion of each value can be calculated from the following conversion formula:
y=0.299r+0.587g+0.114b
u=-0.169r-0.3313g+0.5b
v=0.5r-0.4187g-0.0813b
Where y represents brightness, and u and v represent colors.

Data sampling is also required after the conversion is complete. The commonly used sampling ratio is 4:1:1 or 4:2:2. Because every two rows of data are kept only one row after the work is done, the amount of image data that is sampled is compressed to half the original.

2.DCT Transform

DCT (discrete consine Transform) is the process of separating the high-frequency and low-frequency information by transforming the image signal in the frequency domain. Then the high-frequency part of the image (i.e. image details) is compressed to achieve the compression image data.
First, the image is divided into multiple 8*8 matrices. Then the DCT transform is used for each matrix (the transformation formula is abbreviated). After the transformation, a frequency coefficient matrix is obtained, in which the frequency coefficients are floating-point numbers.

3. Quantification

Since the code used in the subsequent coding process is an integer, it is necessary to quantify the transformed frequency coefficients and convert them to integers.
Due to the data quantization, the data in the matrix are approximate, and the original image data has a difference, this difference is caused by the image compression distortion of the main reasons.
In this process, the selection of quality factors is of paramount importance. The value is too large to increase the compression ratio, but the image quality is poor, conversely, the smaller the quality factor (minimum 1), the better the image reconstruction quality, but the lower the compression ratio. In this respect, ISO has developed a set of standard quantization values for use by the JPEG code implementation.

4. Code

From the previous process we can see that the color conversion finished before coding, the image has not been further compressed, DCT transform and quantization can be said to be prepared for the coding phase.
The coding adopts two kinds of mechanisms: one is 0-value travel length coding and the other is Entropy coding (Entropy coding).
In JPEG, a curved irresolute sequence is used to arrange the elements of the matrix in the normal direction of the diagonal of the matrix. The advantage of this is that the elements near the upper-left corner of the matrix are arranged in front of the stroke, and the matrix elements arranged at the back of the stroke are basically 0 values. Stroke length coding is a very simple and commonly used encoding method, which is no longer to repeat.

Coding is actually an encoding method based on statistical characteristics. Huffman encoding or arithmetic encoding is allowed in JPEG

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.