Image Compression Technology and Image Format (I)

1 Foreword

The digitized data of bitmap manuscripts is very large, and it occupies a lot of space when stored on a hard disk, and it brings a lot of inconvenience to transmission, so image compression has been widely used. The purpose of compression is to meet the requirements of storage capacity and transmission bandwidth, and the price paid is a large number of calculations.

Image compression is mainly based on two basic facts. First, there are many duplicate data in the image data. Using mathematical methods to represent these duplicate data can reduce the amount of data. Second, human eyes have a limit to the identification of image details and colors, and the part that exceeds the limit is removed. Reached the purpose of compressing data. The compression technique that utilizes the former fact is a lossless compression technique, that is, the compressed image data is exactly the same after uncompressed and restored, without distortion, such as a TIFF image file format; the compression technique using the latter fact is a lossy compression technique, ie The compressed image data is different from that when it is not compressed, but it does not affect people's misunderstanding of the information expressed in the original data, such as the JPEG image file format. The actual image compression is actually implemented using a variety of lossy and lossless compression techniques.

In essence, lossless compression removes duplicate data and greatly reduces the size of the image to be saved on disk. However, the lossless compression method does not reduce the memory footprint of the image, because when the image is read from the disk, the software will fill in the missing pixels with the appropriate color information. If you want to reduce the amount of memory the image consumes, you must use a lossy compression method. Admittedly, the use of lossy compression technology can greatly compress the image data, but it will affect the image quality. If it is only displayed on the screen, there is little difference in the degree of human eye recognition. However, if an image that has been processed through lossy compression techniques is printed or printed in high resolution, the image quality will be significantly damaged.

2 The most common image lossless compression technology

The following is a brief introduction to the currently most used and most mature lossless compression techniques: RLE coding, LZW coding, Huffman coding, and so on.

1) Stroke Length Code (RLE)

There are many such images in reality: an image has many tiles of the same color. In these tiles, many rows have the same color, or there are many consecutive pixels in a row with the same pixel values. In this case, it is not necessary to store the color value of each pixel. Instead, it is only necessary to store the color value of one pixel and the number of pixels having the same color, or to store the color value of one pixel, and to have the same color value. Rows. This kind of compression encoding is called run-length encoding and is often expressed as run-length encoding (RLE).

If there is a grayscale image, the pixel value of the nth row is as shown in Fig. 1.

The code obtained using the RLE encoding method is. This method is easy to implement and very effective for compression coding of strings with long repetition values, such as computer-generated images and large-area continuous shadows or images of the same color. However, for natural images with rich colors, they are incapable of having the same color on the same line, and fewer consecutive lines with the same color values ​​on successive lines. If you still use RLE to encode the compressed image, it will make the data The amount is getting bigger, but this is not to say that the RLE coding method is not suitable for the compression of natural images. On the contrary, RLE is really indispensable in the compression of natural images. It is just that RLE cannot be simply used as an encoding method, but needs to be Compression coding technology is used in combination. Many bitmap file formats are encoded using run length, such as TIFF, BMP, PCX, GEM, and so on.

2) LZW coding

This is the abbreviation of the names of the three inventors (Lempel, Ziv, Welch). The principle is to match each byte value of the image data with the value of the next byte into a character pair, and for each character For setting a code. When the same character pair reappears, the character pair is replaced with a letter, and then the character is paired with the next character, as shown in Figure 2.

An important feature of the LZW encoding principle is that the code can not only replace a string of data with the same value, but also replace a string of data with different values. In the image data, if there are some data with different values ​​often repeated, you can also find a code to replace these data strings. In this respect, the LZW compression principle is superior to RLE.
(to be continued)

Pet Clothes

Pet Clothes,Pet Shirt,Pet Fashion Clothes,Dog Clothes

Centrifugal Pump Co., Ltd. , http://www.nbbabyproduct.com

Posted on