Test Lah
Test Lah
Today
Redundancy
Definitions
data
data redundancy (i.e., data after compression)
Compression ratio
Relative redundancy
Coding Redundancy
Some gray levels are more common than other.
Interpixel redundancy
The same gray level may cover
a large area.
Psycho-Visual Redundancy
The eye can only resolve about
32 gray levels locally.
Image Compression
Image compression can be:
Reversible (lossless), with no loss of information.
The image after compression and decompression is
identical to the original image. Often necessary in image
analysis applications.
The compression ratio is typically 2 to 10 times.
Non reversible (lossy), with loss of some information.
Lossy compression is often used in image communication,
compact cameras, video, www, etc.
The compression ratio is typically 10 to 30 times.
Image compression
Reducing the amount of data required to represent an
image.
Enabling efficient image storing and transmission.
Solution
Let a number of test persons rate the image quality of the
images on a scale. This will result in a subjective measure
of image quality, or rather fidelity, but it will be based on
how we perceive the quality of the images.
10
11
image with
gray levels is
12
13
Huffman Coding
First
1. Sort the gray levels by decreasing probability
2. Sum the two smallest probabilities.
3. Sort the new value into the list.
4. Repeat 1 to 3 until only two probabilities remains.
Second
1. Give the code 0 to the highest probability, and the code 1 to
the lowest probability in the summed pair.
2. Go backwards through the tree one node and repeat from 1
until all gray levels have a unique code.
14
15
16
17
18
19
20
21
Huffman Coding
First
1. Sort the gray levels by decreasing probability
2. Add the two smallest probabilities.
3. Sort the new value into the list.
4. Repeat 1 to 3 until only two probabilities remains.
Second
1. Give the code 0 to the highest probability, and the code 1 to
the lowest probability in the summed pair.
2. Go backwards through the tree one node and repeat from 1
until all gray levels have a unique code.
22
23
24
25
26
27
28
29
30
Huffman Coding
The Huffman code is completely reversible, i.e., lossless.
The table for the translation has to be stored together with
the coded image.
The resulting code is unambiguous.
That is, for the previous example, the encoded string
011011101011 can only be parsed into the code
words 0, 110, 1110, 1011 and decoded as 7, 4, 5,
0.
The Huffman code does not take correlation between
adjacent pixels into consideration.
31
Interpixel Redundancy
32
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).
56 56 56 82 82 82 83 80
E.g.,
56 56 56 56 56 80 80 80
33
Difference Coding
Keep the first pixel in a row. The rest of the pixels are
stored as the difference to the previous pixel
Example:
original 56 56 56 82 82 82 83 80 80 80 80
code
56 0 0 26 0 0 1 -3 0 0 0
34
35
36
Huffman Coding
Lavg=3.01
CR=4/3.01=1.33
37
Lavg=2
CR=4/2=2
LZW Coding
LZW, Lempel-Ziv-Welch
In contrast to Huffman with variable code length LZW uses fixed
lengths of code words which are assigned to variable length
sequences of source symbols.
The coding is done from left-to-right and row-by-row.
Requires no a priori knowledge of the probability of occurrence of
the symbols to be encoded.
Removes some of the interpixel redundancy.
During encoding a dictionary or code-book with symbol
sequences is created which is recreated when decoding.
38
Psycho-Visual Redundancy
If the image will only be used for visual observation much of the
information is usually psycho-visual redundant. It can be removed
without changing the visual quality of the image. This kind of
compression is usually lossy.
50 kB (uncompressed TIFF)
5 kB (JPEG)
39
Transform Coding
40
41
3839
90 %
2086
80 %
1711
60 %
1287
40 %
822
20 %
533
10 %
380
5%
42
43
44
45
46
Image analysis
Lossless formats are vital. TIFF supports a wide range of different
bit depths and lossless compression methods.
Images for use on the web
JPEG for photos (JPEG2000), PNG for illustrations. GIF for small
animations. Vector format: SVG, nowadays supported by web
browsers.
Line art, illustrations, logotypes, etc.
Lossless formats such as PNG etc. (or a vector format)
47