Sei sulla pagina 1di 11

JPEG Image Compression

JPEG: Joint Photographic Experts Group. JPEG: compression algorithm, NOT a file format. The original JPEG format was JFIF and later SPIFF. Current popular choices include CCube JFIF; Adobe TIFF/JPEG. 4-step process: 1. Transforming RGB to YIQ/YUV, separating intensity from color 2. Identifying redundant data using a Discrete Cosine Transformation (DCT) 3. Quantizing remaining data 4. Encoding the result to minimize storage requirements

1/30/2004

JPEG Image Compression I


Step I: Transforming RGB to YIQ/YUV, separating intensity from color.

Rationale: pursuing higher compression of color as opposed to luminance.

1/30/2004

JPEG Image Compression II


Step II: Identifying redundant data using a Discrete Cosine Transformation Image divided in groups of 8x8 pixels

Each block is analyzed using a Discrete Cosine Transform


1/30/2004 3

JPEG Image Compression II


DCT: similar to FT; only real (cosine) part is kept. Identifies average value (dc coefficient) and remaining components (ac coefficients).

1/30/2004

JPEG Image Compression III


Step III: Quantizing remaining data Lossy process. DCT coefficients are divided by a constant value (different for each block) and the results are rounded to the nearest integer. Block parameters stored in quantization table(s). Results in a reduction of coefficients.
1/30/2004 5

JPEG Image Compression IV


Step IV: Encoding the result to minimize storage requirements Lossless encoding (e.g. Huffmann or arithmetic coding).

1/30/2004

JPEG Image Compression


For examples check out:
http://www.agfanet.com/en/cafe/photocourse/digicourse/lesson6/cont_chapter04.php3

and the JPEG FAQ:


http://www.faqs.org/faqs/jpeg-faq/part1/

1/30/2004

JPEG Image Compression


100% quality -> 84% size reduction 20% quality -> ~96% size reduction

1/30/2004

JPEG Image Compression


100% quality -> 84% size reduction Minimal quality -> ~99% size reduction

1/30/2004

Lossless Coding
Lossless compression is possible because there is significant redundancy in images. Examples of redundancy: spatial correlation among neighboring pixels in still imagery, temporal correlation in video. In lossless compression decoded image is identical to original encoded image.

Input Image

Bitstream

Transformation

Data-to-Symbol Mapping

Lossless Symbol Coding

1/30/2004

10

Data-to-Symbol Mapping
Mapping data into symbols Run-length coding (RLC): maps a sequence of numbers into a sequence of symbol pairs (run,value). 11111000110101000000 ----RLC----> (5,1)(3,0)(2,1)(1,0)(1,1)

1/30/2004

11

Lossless Symbol Coding


Symbol Coding: Assigns binary codewords to input symbols. Statistical schemes: Shorter codewords assigned to symbols that occur more frequently (variablelength coding VLC; entropy coding) e.g. Huffman, arithmetic coders. Dictionary-based schemes: Fixed-length codewords for variable-length strings of symbols (e.g. LempelZiv)
1/30/2004 12

Scheme Selection Criteria


Compression Efficiency: compression ratio CR=(Bits of original input image)/(Bits of compressed bitstream) Coding delay expressed as total time to encode and decode input. Implementation complexity measured in terms of total number of arithmetic operations and memory requirements. Robustness to transmission errors. Scalability in resolution and bit rate.
1/30/2004 13

Huffman Coding
Premise: 1) if P(sk)>P(sj) then lk<lj. 2) With symbols listed in order of decreasing probabilities the last two symbols are assigned codewords that have the same length and differ in their final bit only.

1/30/2004

14

Huffman Coding
Ranking symbol probabilities

Iterative definition of tree structure

1/30/2004

15

Huffman Coding

1/30/2004

16

Huffman Coding

1/30/2004

17

Huffman Coding

1/30/2004

18

JPEG vs. GIF


Color depth: JPEG stores full color info (24 bits/pixel). GIF stores only 8 bits/pixel (intended for inexpensive color displays) Edge preservation: JPEG tends to blur sharp edges (esp. in high compression) GIF does very well with graphics images (e.g. line drawings)
1/30/2004 19

JPEG vs. GIF (cont.)


B&W imagery: JPEG is not suitable for two-tone imagery GIF is lossless for gray scale images (up to 256 gray values)

1/30/2004

20

Compression performance
JPEG: 10:1 to 20:1 compression without visible loss (effective storage requirement drops to 1-2 bits/pixel) 30:1 to 50:1 compression with small to moderate visual deterioration 100:1 compression for low quality applications GIF: 3:1 compression by reducing color space to 8 bits LZW coding may improve compression up to 5:1

1/30/2004

21

LZW Compression Algorithm


Lempel-Ziv-Welch Algorithm:
w = NIL; while ( read a character k ) { if wk exists in the dictionary w = wk; else add wk to the dictionary; output the code for w; w = k; }

Argument: the requires 5 bytes (80 bits) to encode by assigning a single symbol to it we can express it with 9 bits

1/30/2004

22

Potrebbero piacerti anche