Presentation is loading. Please wait.

Presentation is loading. Please wait.

Image Compression. Data and information Data is not the same thing as information. Data is the means with which information is expressed. The amount of.

Similar presentations


Presentation on theme: "Image Compression. Data and information Data is not the same thing as information. Data is the means with which information is expressed. The amount of."— Presentation transcript:

1 Image Compression

2 Data and information Data is not the same thing as information. Data is the means with which information is expressed. The amount of data can be much larger than the amount of information. Data that provide no relevant information = redundant data or redundancy. Image coding or compression has a goal to reduce the amount of data by reducing the amount of redundancy

3 Definitions n1 = data. n2 = data − redundancy (i.e., data after compression). Compression ratio = CR = n1/n2 Relative redundancy = RD = 1 − 1/CR

4 Definitions n1 = data. n2 = data − redundancy (i.e., data after compression). Compression ratio = CR = n1/n2 Relative redundancy = RD = 1 − 1/CR

5 Different Types of Redundancy CR Coding Redundancy. IR Interpixel Redundancy. PVR Psycho-Visual Redundancy

6 Image compression and decompression

7 Image Compression Image compression can be: Reversible (loss less), with no loss of information. –A new image is identical to the original image (after decompression). –Reversibility is necessary in most image analysis applications. –The compression ratio is typically 2 to 10 times. –Examples are Huffman coding and run-length coding. Non reversible (lossy), with loss of some information. –Lossy compression is often used in image communication, video,WWW, etc. –It is usually important that the image visually is still nice. –The compression ratio is typically 10 to 30 times.

8 Objective measures of image quality

9 Subjective measures of image quality Let a number of test persons grade the images as bad/acceptable/good etc.

10 Coding redundancy Use shorter code words fore the more common gray levels and longer code words for the less common gray levels. This is called Variable Length Coding. The amount of data in an M × N image with L gray levels is equal to M × N × L avg, where l(r k ) is the number of bits used to represent gray level r k, and p(r k ) is the probability of gray level r k in the image.

11 Example 3-bit image

12 Interpixel Redundancy There is often correlation between adjacent pixels, i.e., the value of the neighbors of an observed pixel can often be predicted from the value of the observed pixel. Coding methods: –Run-Length coding. –Difference coding

13 Run-length coding Every code word is made up of a pair (g, l) where g is the gray level, and l is the number of pixels with that gray level (length, or “ run ” ). E.g., 56 56 56 82 82 82 83 80 56 56 56 56 56 80 80 80 creates the run-length code (56, 3)(82, 3)(83, 1)(80, 4)(56, 5). The code is calculated row by row. Very efficient coding for binary data. Important to know position, and the image dimensions must be stored with the coded image. Used in most fax machines.la University) Image Coding an

14 Run-length coding

15

16 Compression Achieved Original image requires 3 bits per pixel (in total - 8x8x3=192 bits). Compressed image has 29 runs and needs 3+3=6 bits per run (in total - 174 bits or 2.72 bits per pixel).

17 Difference coding f (x i ) = E.g., original 56 56 56 82 82 82 83 80 80 80 80 Code f(x i ) 56 0 0 26 0 0 1 −3 0 0 0 The code is calculated rob by row. Both run-length coding, and difference coding are reversible, and can be combined with, e.g., Huffman coding X i if i = 0, x i − x i-1 if i > 0

18 Example of difference

19

20 The Huffman code Yields the smallest possible number of unique code symbols per source symbol. –Step 1. –1 1. Sort the gray levels by decreasing probability. –2 2. Add the two smallest probabilities. 3. Sort the new value into the list. 4. Repeat until only two probabilities remain. –Step 2. 2. 1. Give the code 0 to the highest probability, and the code 1 to the lowest probability in the present node. 2. Go backwards through the tree and add 0 to the highest and 1 to the lowest probability in each node until all gray levels have a unique code

21 Example Huffman coding

22 Huffman code of original image Lavg = 3.1 la

23 Example of Huffman coding

24

25 The Huffman code The Huffman code results in unambiguous code. The code is reversible without loss. The table for the translation of the code has to be stored together with the coded image. The Huffman code does not take correlation between adjacent pixels into consideration.

26 Chain Coding

27 Eight directions are represented with 3 bits. Upper left corner of the object (7,3) is selected to be the starting point (upper left corner of the image is (0,0)). The edge of the object is followed clockwise until we get back to the starting point.

28 Chain Coding

29

30 We get the following chain code for the object: 7,6,7,7,6,6,5,6,3,3,3,3,4,1,1,1,2. Binary code: starting point directions 0111 0011 111 110 111 111 110... 010 Bits needed: 2x4+17x3=59 (against 256 for uncompressed image) 7→ 0.23 bits/pixel (against 1 bit/pixel for uncompressed image).

31 Lossy Compression Transform Coding : Coefficients can be quantized, dropped and coded causing a controlled damage to the image. Possible Transforms: –DFT, DCT, Hadamard etc. MixedTime-Frequency presentations e.g.: Gabor, Waveletsetc

32 Transform coding Divide the image into n × n sub-images. Transform each sub-image using a reversible transform (e.g., the Hotelling transform, the discrete Fourier transform (DFT) or the discrete cosine transform (DCT)). Quantify, i.e., truncate the transformed image (e.g., by using DFT,and DCT frequencies with small amplitude can be removed without much information loss). The quantification can be either image dependent (IDP) or image independent (IIP). Code the resulting data, normally using some kind of “ variable length coding ”, e.g., Huffman code. The coding is not reversible (unless step 3 is skipped). Divide the image into n × n sub-images. 2

33 Some common image formats JPEG Joint Photographic Experts Group - Exists in many different versions but is always some kind of transformation coding. JPEG is not reversible due to quantification. MPEG Motion Picture Experts Group - Similar to JPEG, but the motion in comparison to the previous image is calculated,and used in the compression.

34 Example of JPEG compression

35 Some more common image formats LZW (Lempel-Ziv-Welch) A “ word-based ” code. The data is represented by pointers to a library of symbols (see Huffman code). LZW compression is loss less, and can often be chosen when TIFF (Tagged Image File Format) images are stored. The result is a smaller file which usually takes a bit longer to decode. An image file directory (set of symbols) is included in the header. GIF (Graphics Interchange Format) Creates a coding for color images where each color is coded by only a few bits (usually three). GIF also uses LZW compression for storage and transfers. GIF is fully reversible (loss less) if less then 256 colors are present in the original image. Remember that the time used for coding, and decoding is important when choosing coding method

36 Choice of image formats Images used for image analysis should always be stored in a loss less format. Images for the WWW have to be either GIF, JPEG or PNG (due to the license issues GIF). Chose GIF for graphs and hand drawn figures with few color shades (JPEG transform coding and truncation can cause artifacts around sharp edges). Chose JPEG for photos and figures with many colors, and smooth transitions between colors (GIF reduces the number of colors to 256).

37 JPEG: Encoding and Decoding Reconstructed


Download ppt "Image Compression. Data and information Data is not the same thing as information. Data is the means with which information is expressed. The amount of."

Similar presentations


Ads by Google