Você está na página 1de 24

1

o Lossless
Information preserving Low compression ratios

o Lossy
Not information preserving High compression ratios

Trade-off: image quality vs compression ratio

o Lossless algorithms do not change the content of a file. If you compress a file and then decompress it, it has not changed. The following algorithms are lossless: Flate/deflate compression Huffman compression LZW compression RLE compression
o Lossy algorithms achieve better compression ratios by selectively getting rid of some of the information in the file. Such algorithms can be used for images or sound files but not for text or program data. The following algorithms are lossy : JPEG compression MPEG compression

Run Length encoding (RLE). Lample Zie welch (LZW). Flate / Deflate . Huffman . JPEG .

RLE is probably the easiest compression algorithm there is. It replaces sequences of the same data values within a file by a count number and a single value. Suppose the following string of data (17 bytes) has to be compressed: ABBBBBBBBBCDEEEEF Using RLE compression, the compressed file takes up 10 bytes and could look like this: A*8BCD*4EF

Input: string of characters Internal: dictionary of (codewords, words) Output: string of codewords and characters. Codewords are distinct from characters. In algorithm, w is a string, c is character and w+c means concatenation. When adding a new word to the dictionary, a new code word needs to be assigned.

Huffman compression belongs into a family of algorithms with a variable codeword length. That means that individual symbols (characters in a text file for instance) are replaced by bit sequences that have a distinct length. So symbols that occur a lot in a file are given a short sequence while other that are used seldom get a longer bit sequence. A practical example will show you the principle: Suppose you want to compress the following piece of data: ACDABA Since these are 6 characters, this text is 6 bytes or 48 bits long. With Huffman encoding, the file is searched for the most frequently appearing symbols (in this case the character A occurs 3 times) and then a tree is build that replaces the symbols by shorter bit sequences. In this particular case, the algorithm would use the following substitution table: A=0, B=10, C=110, D=111. If these code words are used to compress the file, the compressed data look like this: 01101110100

The JPEG algorithms performs its compression in four phases :


1) First, the JPEG algorithms first cuts up an image in separate blocks of 88 pixels. The compression algorithm is calculated for each separate block, which explains why these blocks or groups of blocks become visible when too much compression is applied. 2) The next step in the compression process is to apply a Discrete Cosine Transform (DCT) for the entire block. DCT is a complex process that is let loose on each individual pixel. It replaces actual color data for each pixel for values that are relative to the average of the entire matrix that is being analyzed. This operation does not compress the file, it simply replaces 88 pixel values by an 88 matrix of DCT coefficients.

3) Once this is done, the actual compression can start. First the compression software looks at the JPEG image quality the user requested (e.g. Photoshop settings like low quality, medium quality,) and calculates two tables of quantization constants, one for luminance and one for chrominance. Once these tables have been constructed, the constants from the two tables are used to quantize the DCT coefficients. Each DCT coefficient is divided by its corresponding constant in the quantization table and rounded off to the nearest integer. The result of quantizing the DCT coefficients is that smaller, unimportant coefficients will be replaced by zeros and larger coefficients will lose precision. It is this rounding-off that causes a loss in image quality.

4) The resulting data are a list of streamlined DCT coefficients. The last step in the process is to compress these coefficients using either a Huffman or arithmetic encoding scheme. Usually Huffman encoding is used.

By putting 2 compression algorithms on top of each other, JPEG achieves remarkable compression ratios. The downside of JPEG compression is that the algorithm is only designed for continuous tone images (remember that the P in JPEG stands for Photographic). JPEG not does not lend itself for images with sharp changes in tone. JPEG Making image files smaller is a plus for transmitting files across networks and for archiving libraries of images. Being able to compress a 2 Mbyte fullcolor file down to, say, 100 Kbytes makes a big difference in disk space and transmission time! And JPEG can easily provide 20:1 compression of full-color data. JPEG is that it stores full color information: 24 bits/pixel (16 million colors).

After the above, we conclude that the best choice for image compression is JPEG algorithm . But!!!!! (thats correct before 2000)

The JPEG2000 compression algorithm was released by an ISO standardization committee in January 2000. It is based on the existing JPEG specifications and adds important things to the existing standard.
The JPEG 2000 is a new image coding system that uses state-ofthe-art compression techniques based on wavelet technology.

o DWT = intra-component decorrelation concentrate image energy in a small area o No blocking artefacts at high compression ratios o Enables multi-resolution image representation

Improved compression efficiency. Lossy to lossless compression. Single compression / Multiple decompression. Scalability : - Resolution. - Quality (SNR scalability).

Region of Interest Coding (ROI). Error Resilience.

JPEG

JPEG2000

Decompression

Compression

storage

2.6 kBytes (1:100)

1.6 % download 2.2 % download 8.0 % download 26.4 % download 100 % download

Embedded error : 16 bytes set to 0 in the middle of the compressed file.

JPEG

JPEG2000

JPEG 2000 offers numerous advantages over the old JPEG standard. One main advantage is that JPEG 2000 offers both lossy and lossless compression in the same file stream, while JPEG usually only utilizes lossy compression. A second advantage of JPEG 2000 over JPEG is that JPEG 2000 is able to offer higher compression ratios for lossy compression. Another advantage of JPEG 2000 is its ability to display images at different resolutions and sizes from the same image file. With JPEG, an image file was only able to be displayed a single way, with a certain resolution.

SO , the best choice for image compression is

JPEG2000 algorithm

Você também pode gostar