Data Compression
Data Compression
Part II:
Multimedia Data Compression
Chapter 7,8,9,10:
Lossless Compression Algorithms
1
In this Part we examine the role played in multimedia by data
compression, perhaps the most important enabling
technology that makes modern multimedia systems possible.
2
7.1 Introduction
Compression: the process of coding that will effectively
reduce the total number of bits needed to represent
certain information.
Figure 7.1 depicts a general data compression scheme, in which
compression is performed by an encoder and decompression
is performed by a decoder.
We call the output of the encoder codes or codewords. The intermediate medium could either be
data storage or a communication/computer network.
3
7.1 Introduction
If the compression and decompression processes induce no
information loss, then the compression scheme is lossless;
otherwise, it is lossy.
Compression ratio:
(7.1)
6
Distribution of Gray-Level Intensities
The image histogram is a way of calculating the probability pi of
having pixels with gray-level intensity i in the image.
7
Distribution of Gray-Level Intensities
9
7.3 Run-Length Coding
• RLC is one of the simplest forms of data compression.
The basic idea is that if the information source has the property that
symbols tend to form continuous groups, then such symbol and the
length of the group can be coded.
Consider a screen containing plain black text on a solid white
background.
There will be many long runs of white pixels in the blank space, and
many short runs of black pixels within the text. Let us take a
hypothetical single scan line, with B representing a black pixel and W
representing white:
WWWWWBWWWWBBBWWWWWWBWWW
If we apply the run-length encoding (RLE) data compression
algorithm to the above hypothetical scan line, we get the following:
5W1B4W3B6W1B3W
The run-length code represents the original 23 characters in only 14.
10
7.4 Variable-Length Coding
Variable-length coding (VLC) is one of the best-known
entropy coding methods
11
7.4.1 Shannon–Fano Algorithm
To illustrate the algorithm, let us suppose the symbols to be
coded are the characters in the word HELLO.
The frequency count of the symbols is
Symbol H E L O
Count 1 1 2 1
The encoding steps of the Shannon–Fano algorithm can be
presented in the following top-down manner:
1. Sort the symbols according to the frequency count of their
occurrences.
2. Recursively divide the symbols into two parts, each with
approximately the same number of counts, until all parts
contain only one symbol.
12
7.4.1 Shannon–Fano Algorithm
A natural way of implementing the above procedure is to
build a binary tree.
As a convention, let us assign bit 0 to its left branches and 1
to the right branches.
Initially, the symbols are sorted as LHEO.
As Fig. 7.3 shows, the first division yields two parts: L with a
count of 2, denoted as L:(2); and H, E and O with a total
count of 3, denoted as H, E, O:(3).
The second division yields H:(1) and E, O:(2).
The last division is E:(1) and O:(1).
13
7.4.1 Shannon–Fano Algorithm
15
16
Fig. 7.4 Another coding tree for HELLO by Shannon-
Fano.
17
Table 7.2: Another Result of Performing Shannon-Fano
on HELLO (see Fig. 7.4)
18
7.4.1 Shannon–Fano Algorithm
The Shannon–Fano algorithm delivers satisfactory coding results
for data compression, but it was soon outperformed and
overtaken by the Huffman coding method.
First presented by Huffman in a 1952 paper, this method
attracted an overwhelming amount of research and has
been adopted in many important and/or commercial
applications, such as fax machines, JPEG, and MPEG.
In contradistinction to Shannon–Fano, which is top-down,
the encoding steps of the Huffman algorithm are described
in the following bottom-up manner. Let us use the same
example word, HELLO.
A similar binary coding tree will be used as above, in which
the left branches are coded 0 and right branches 1. A simple
list data structure is also used.
19
7.4.1 Shannon–Fano Algorithm
Algorithm 7.1 (Huffman Coding).
1.Initialization: put all symbols on the list sorted according
to their frequency counts.
2. Repeat until the list has only one symbol left.
(a) From the list, pick two symbols with the lowest
frequency counts. Form a Huffman subtree that has these
two symbols as child nodes and create a parent node for
them.
(b) Assign the sum of the children’s frequency counts to the
parent and insert it in to the list, such that the order is
maintained.
(c) Delete the children from the list.
3. Assign a code word for each leaf based on the path from
the root. 20
7.4.1 Shannon–Fano Algorithm
21
7.4.1 Shannon–Fano Algorithm
In Fig. 7.5, new symbols P1, P2, P3 are created to refer to the
parent nodes in the Huffman coding tree. The contents in
the list are illustrated below:
After initialization: L H E O
After iteration (a): LP1H
After iteration (b): LP2
After iteration (c): P3
22
7.4.1 Shannon–Fano Algorithm
For this simple example, the Huffman algorithm apparently
generated the same coding result as one of the Shannon–
Fano results we have shown, although the results are usually
better.
The average number of bits used to code each character is
also 2, (i.e., (1 + 1 + 2 + 3 + 3)/5 = 2).
23
7.5 Dictionary-Based Coding
24
7.5 Dictionary-Based Coding
[2] https://www.youtube.com/watch?v=MQM_DsX-LBI
25
End of Chapter 7
26
Fundamentals of Multimedia
Part II:
Multimedia Data Compression
Chapter 8 :
Lossy Compression Algorithms
27
8.1 Introduction
The compression ratio for image data using lossless
compression techniques (e.g., Huffman Coding, Arithmetic
Coding, LZW) is low when the image histogram is
relatively flat.
28
8.2 DistortionMeasures
To quantitatively describe how close the approximation is
to the original data, some form of distortion measure is
required.
A distortion measure is a mathematical quantity that
specifies how close an approximation is to its original,
using some distortion criteria.
When looking at compressed data, it is natural to think of
the distortion in terms of the numerical difference
between the original data and the reconstructed data.
29
8.2 DistortionMeasures
Of the many numerical distortion measures that have
been defined is the the mean square error (MSE) .
If we are interested in the average pixel difference, the
mean square error (MSE) 𝜎 2 is often used. It is defined as
30
End of Chapter 8
31
Fundamentals of Multimedia
Part II:
Multimedia Data Compression
Chapter 9:
Image Compression Standards
32
Recent years have seen an explosion in the availability of
digital images, because of the increase in numbers of
digital imaging devices such as smart phones, webcams,
digital cameras, and scanners.
33
9.1 image compression standard
Some current standards are:
JPEG
JPEG2000 standard
JPEG-LS Standard
JBIG Standard
JBIG2 Standard
34
End of Chapter 9
35
Fundamentals of Multimedia
Part II:
Multimedia Data Compression
Chapter 10 :
Basic Video Compression Techniques
36
As discussed in Chap. 7, the volume of uncompressed
video data could be extremely large.
38
10.1 Introduction to Video Compression
39
10.1 Introduction to Video Compression
Three types of pictures (or frames) are used in video compression: I, P, and B frames.
An I-frame (Intra-coded picture), a complete image, like a JPG or BMP image file.
P and B frames hold only part of the image information (the part that changes
between frames), so they need less space in the output file than an I-frame.
A P-frame (Predicted picture) holds only the changes in the image from the
previous frame. For example, in a scene where a car moves across a stationary
background, only the car's movements need to be encoded. The encoder does not
need to store the unchanging background pixels in the P-frame, thus saving space.
P-frames are also known as delta-frames.
41
End of Chapter 10
42
MPEG-1
MPEG: Moving Pictures Experts Group, established in 1988 for the
development of digital video.
43
Group Worksheet
44
END
45
Kingdom of Saudi Arabia المملكة العربية السعودية
Ministry of Education وزارة التعليم
Umm AlQura University جامعة أم القرى
Adam University College الكلية الجامعية أضم
Computer Science Department قسم الحاسب اآللي
It is edited for
Multimedia Systems Course 6803316-3
by:
T.Mariah Sami Khayat
Teacher Assistant @ Adam University College
For Contacting:
[email protected]
46