Image Coding and Compression Lecture 17 Patrick Karlsson [email protected]Centre for Image Analysis Uppsala University Computer Assisted Image Analysis May 19 2006 Karlsson (Uppsala University) Image Coding and Compression Image Analysis 1 / 33 Reading Instructions and Assignment Chapters and Assignment for This Lecture Chapter 8.1 - 8.3.1, 8.4 - 8.4.3, 8.5.1 - 8.5.2 and 8.6 in Gonzales-Woods. The suggested problem for this lecture is not a problem from the course literature (see next slide). Karlsson (Uppsala University) Image Coding and Compression Image Analysis 2 / 33
17
Embed
Reading Instructions and Assignment - Uppsala …...Suggested problem for lecture 17 Huffman coding Calculate the Huffman code on the image to the right. Show all steps in the coding
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Basic idea: Different gray levels occur with different probability(non uniform histogram). Use shorter code words fore the morecommon gray levels and longer code words for the less commongray levels. This is called Variable Length Coding.
The amount of data in an M × N image with L gray levels is equalto M × N × Lavg , where
Lavg =L−1∑k=0
l(rk )pr (rk ),
l(rk ) is the number of bits used to represent gray level rk , andp(rk ) is the probability of gray level rk in the image.
Yields the smallest possible number of unique code symbols persource symbol.Step 1.
1 Sort the gray levels by decreasing probability.2 Add the two smallest probabilities.3 Sort the new value into the list.4 Repeat until only two probabilities remain.
Step 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 aunique code.
Interpixel RedundancyAlso called spatial or geometric redundancy
There is often correlation between adjacent pixels, i.e., the valueof the neighbors of an observed pixel can often be predicted fromthe value of the observed pixel.
Run-length codingEvery code word is made up of a pair (g, l) where g is the graylevel, and l is the number of pixels with that gray level (length, or“run”).E.g.,
56 56 56 82 82 82 83 8056 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 bestored with the coded image.Used in most fax machines.
Divide the gray level/color image into series of binary images (withone image per bit). Code each image separately using the abovedescribed methods. An 8-bit image will be represented by 8 codedbinary images.
If the image will only be used for visual observation (i.e.,illustrations on the web, etc.), much of the information is usuallypsycho-visually redundant. It can be removed without changingthe visual quality of the image. This kind of compression is usuallyirreversible.
1 Divide the image into n × n sub-images.2 Transform each sub-image using a reversible transform (e.g., the
Hotelling transform, the discrete Fourier transform (DFT) or thediscrete cosine transform (DCT)).
3 Quantify, i.e., truncate the transformed image (e.g., by using DFT,and DCT frequencies with small amplitude can be removedwithout much information loss). The quantification can be eitherimage dependent (IDP) or image independent (IIP).
4 Code the resulting data, normally using some kind of “variablelength coding”, e.g., Huffman code.
The coding is not reversible (unless step 3 is skipped).
JPEG Joint Photographic Experts Group - Exists in manydifferent versions but is always some kind oftransformation coding. JPEG is not reversible due toquantification.
MPEG Motion Picture Experts Group - Similar to JPEG, but themotion in comparison to the previous image is calculated,and used in the compression.
LZW (Lempel-Ziv-Welch) A “word-based” code. The data isrepresented by pointers to a library of symbols (seeHuffman code). LZW compression is loss less, and canoften be chosen when TIFF (Tagged Image File Format)images are stored. The result is a smaller file whichusually takes a bit longer to decode. An image filedirectory (set of symbols) is included in the header.
GIF (Graphics Interchange Format) Creates a coding for colorimages where each color is coded by only a few bits(usually three). GIF also uses LZW compression forstorage and transfers. GIF is fully reversible (loss less) ifless then 256 colors are present in the original image.
Remember that the time used for coding, and decoding is importantwhen choosing coding method!