0% found this document useful (0 votes)
223 views

Multimedia Data Compression: 1 IT 3rd Year, Compiled by Waggari M

Multimedia data compression involves reducing the size of multimedia files such as video and audio to reduce storage and transmission requirements. Without compression, a 90 minute movie would require over 12 GB of storage. Compression works by removing redundant data and can be either lossless, perfectly preserving the original quality, or lossy, sacrificing some quality for higher compression ratios. Common techniques like run length encoding replace repeated values with a single value and count. The type of compression used depends on balancing compression ratio, quality loss, and computational requirements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
223 views

Multimedia Data Compression: 1 IT 3rd Year, Compiled by Waggari M

Multimedia data compression involves reducing the size of multimedia files such as video and audio to reduce storage and transmission requirements. Without compression, a 90 minute movie would require over 12 GB of storage. Compression works by removing redundant data and can be either lossless, perfectly preserving the original quality, or lossy, sacrificing some quality for higher compression ratios. Common techniques like run length encoding replace repeated values with a single value and count. The type of compression used depends on balancing compression ratio, quality loss, and computational requirements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Multimedia Data Compression

IT 3rd year, compiled by Waggari M 1


The Need for Compression
• Take, for example, a video signal with resolution 320x240
pixels and 256 (8 bits) colors, 30 frames per second

• Raw bit rate = 320x240x8x30


= 18,432,000 bits
= 2,304,000 bytes = 2.3 MB

• A 90 minute movie would take 2.3x60x90 MB = 12.44 GB

• Without compression, data storage and transmission would


pose serious problems!

IT 3rd year, compiled by Waggari M 2


Multimedia Data Compression
•Data compression is about finding ways to reduce the
number of bits or bytes used to store or transmit the
content of multimedia data.
–It is the process of encoding information using fewer bits
–For example, the ZIP file format, which provides compression,
also acts as an archiver, storing many source files in a single
destination output file.
•As with any communication, compressed data
communication only works when both the sender and
receiver of the information understand the encoding
scheme.
–Thus, compressed data can only be understood if the decoding
method is known by IT
the3rdreceiver.
year, compiled by Waggari M 3
Is compression useful?
• Compression is useful because it helps reduce the
consumption of expensive resources, such as hard disk
space or transmission bandwidth.
– save storage space requirement: handy for storing files as they
take up less room.
– speed up document transmission time: convenient for transferring
files across the Internet, as smaller files transfer faster.

• On the downside, compressed data must be decompressed


to be used, and this extra processing may be detrimental to
some applications.
– For instance, a compression scheme for video may require
expensive hardware for the video to be decompressed fast enough
to be viewed as it's being decompressed
– The option of decompressing the video in full before watching it
may be inconvenient, and requires storage space for the
decompressed video.IT 3rd year, compiled by Waggari M 4
Trade offs in Data Compression
The design of data compression schemes therefore
involves trade-offs among various factors, including
• the degree of compression
– To what extent the data should be compressed?
• the amount of distortion introduced
– To what extent quality loss is tolerated?
• the computational resources required to compress and
uncompress the data.
– Do we have enough memory required for compressing and
uncompressing the data?

IT 3rd year, compiled by Waggari M 5


Types of Compression
Lossless Lossy Compression
Compression
M M

Lossless Compress Compress with loss

m m
M’  M

Uncompress Uncompress

M M’

M = Multimedia data Transmitted


IT 3rd year, compiled by Waggari M 6
Types of Compression
• Lossless Compression
–Lossless compression can recover the exact original data after compression.
–It is used mainly for compressing symbolic data such as database records,
spreadsheets, texts, executable programs, etc., where exact replication of the
original is essential and changing even a single bit cannot be tolerated.
–Examples: Run Length Encoding (RLE), Lempel Ziv (LZ), Huffman Coding.
• Lossy Compression
–Result in a certain loss of accuracy in exchange for a substantial increase in
compression.
–For visual and audio data, some loss of quality can be tolerated without losing the
essential nature of the data where losses outside visual or aural perception can be
tolerated.
• In audio compression, for instance, non-audible (or less audible) components of the signal are
removed.

• Lossy compression is used for:


–image compression in digital cameras, to increase storage capacities with minimal
degradation of picture quality
–audio compression for Internet telephony & CD ripping, which is decoded by audio
players.
–video compression in DVDs IT with
3rd year,
MPEGcompiled by Waggari M
format. 7
Lossy and Lossless Compression
•Lossless compression does not lose any data in the compression
process.
–Lossless compression is possible because most real-world data has
statistical redundancy. It packs data into a smaller file size by
using a kind of internal shorthand to signify redundant data. If an
original file is 1.5MB, this technique can reduce up to half of the
original size.
–GIF image files and WinZip use lossless compression. For this
reason zip software is popular for compressing program and data
files.
•Lossless compression has advantages and disadvantages.
–The advantage is that the compressed file will decompress to an
exact duplicate of the original file, mirroring its quality.
–The disadvantage is that the compression ratio is not all that high,
precisely because no data is lost.
•To get a higher compression ratio -- to reduce a file significantly
beyond 50% -- you must IT use lossy
3rd year, compression.
compiled by Waggari M 8
Lossy and Lossless Compression
• Lossy compression will strip a file of some of its
redundant data. Because of this data loss, only certain
applications are fit for lossy compression, like graphics,
audio, and video.
–Lossy compression necessarily reduces the quality of the file to
arrive at the resulting highly compressed size.
• Lossy data compression will be guided by research on how
people perceive the data in question.
–For example, the human eye is more sensitive to subtle variations
in luminance (i.e. brightness) than it is to variations in color.
–JPEG image compression works in part by "rounding off" some
of this less-important information.

IT 3rd year, compiled by Waggari M 9


Human visual system
• What characteristics of the human visual system can be exploited
in related to compression of color images and video?
• The eye is basically sensitive to color intensity
– Each neuron is either a rod or a cone . Rods are not sensitive to color.
– Cones come in 3 types: red, green and blue.
– Each responds differently --- Non linearly and not equally for RGB
differently to various frequencies of light.

IT 3rd year, compiled by Waggari M 10


Lossless vs. Lossy compression
• Lossless & lossy compression have become part of our
every day vocabulary due to the popularity of MP3 music
file, JPEG image file, MPEG video file, …
–A sound file in WAV format, converted to a MP3 file will lose much
data as MP3 employs a lossy compression; resulting in a file much
smaller so that several dozen MP3 files can fit on a single storage
device, vs. a handful of WAV files. However the sound quality of
the MP3 file will be slightly lower than the original WAV. Have you
noticed that?
–JPEG uses lossy compression, while GIF follows lossless
compression techniques
• Hence GIF compresses only up to 25%; as a result of which converting a GIF
file to JPEG format will reduce it in size. It will also reduce the quality to
some extent.

• To compress video, graphics or audio, it is our personal


choice and good results depend heavily on the quality of the
original file. IT 3rd year, compiled by Waggari M 11
Example: Lossless vs. lossy compression
• An example of lossless vs. lossy compression is the
following string:
–25.888888888
• This string can be compressed as: 25.9!8
• Interpreted as, "twenty five point 9 eights", the original string is
perfectly recreated, just written in a smaller form.
• In a lossy system it can be compressed as: 26
–In which case, the original data is lost, at the benefit of a smaller
file size
• The two simplest compression techniques are: Zero length
suppression & run length encoding.
–The above is a very simple example of run-length encoding,

IT 3rd year, compiled by Waggari M 12


Run length encoding compression
techniques
• Data often contains sequences of identical bytes. By
replacing these repeated byte sequences with the number
of occurrences, a substantial reduction of data can be
achieved.
• In Run-length encoding, large runs of consecutive
identical data values are replaced by a simple code with
the data value and length of the run, i.e.
(dataValue, LengthOfTheRun)
• This encoding scheme tries to record occurrence of data
value (Xi) along with its run length, i.e.(Xi ,
Length_of_Xi)
IT 3rd year, compiled by Waggari M 13
Run-length Encoding (RLE)
• It compress data by storing runs of data (that is, sequences in which
the same data value occurs in many consecutive data elements) as a
single data value & count.
– This method is useful on data that contains many such runs. Otherwise, It is not
recommended for use with files that don't have many runs as it could
potentially double the file size.
• For example, consider the following image with long runs of white
pixels (W) and short runs of black pixels (B).
WWWWWWWWWWBWWWWWWWWWBBBWWWWWWWWWWWW
• If we apply the run-length encoding (RLE) data compression
algorithm, the compressed code is :
10W1B9W3B12W (Interpreted as ten W's, one B, nine W's, three
B's, …)
• Run-length encoding performs lossless data compression.
• It is used in fax machines. It is relatively efficient because faxed
documents are mostly white space, with occasional interruptions of
black. IT 3rd year, compiled by Waggari M 14
Lossless vs. Lossy compression
• Generally, the difference between the two compression
technique is that:
– Lossless compression schemes are reversible so that the
original data can be reconstructed,
– Lossy schemes accept some loss of data in order to achieve
higher compression.

• These lossy data compression methods typically offer a


three-way tradeoff between
– Computer resource requirement (compression speed, memory
consumption)
– compressed data size and
– quality loss. IT 3rd year, compiled by Waggari M 15
Common compression methods
• Statistical methods:
–It requires prior information about the occurrence of symbols
E.g. Huffman coding and Shannon-Fano coding
• Estimate probabilities of symbols, code one symbol at a time, shorter
codes for symbols with high probabilities

• Dictionary-based coding
–The previous algorithms (both entropy and Huffman) require the
statistical knowledge which is often not available (e.g., live audio,
video).
–Dictionary based coding, such as Lempel-Ziv (LZ) compression
techniques do not require prior information to compress strings.
• Rather, replace symbols with a pointer to dictionary entries

IT 3rd year, compiled by Waggari M 16


Huffman coding
• Developed in 1950s by David Huffman,
widely used for text compression,
multimedia codec and message 0 1
transmission
0 1 D4
• The problem: Given a set of n symbols
1 D3
and their weights (or frequencies), 0
construct a tree structure (a binary tree D D2
1
for binary code) with the objective of
reducing memory space and decoding Code of:
time per symbol.
D1 = 000
• For instance, Huffman coding is D2 = 001
constructed based on frequency of D3 = 01
occurrence of letters in text documents D4 = 1
IT 3rd year, compiled by Waggari M 17
Huffman coding
• The Model could determine raw probabilities of
each symbol occurring anywhere in the input
stream.
pi = # of occurrences of Si
Total # of Symbols
• The output of the Huffman encoder is determined
by the Model (probabilities).
–The higher the probability of occurrence of the symbol,
the shorter the code assigned to that symbol and vice
versa.
–This will enable toIT easily control the most frequently18
3rd year, compiled by Waggari M
How to construct Huffman coding
• Step 1: Create forest of trees for each symbol, t1, t2,… tn
• Step 2 WHILE more than one tree exist DO

• Sort forest of trees according to fallingprobabilities of symbol


occurrence
–Merge two trees t1 and t2 with least probabilities p1 and p2
–Label their root with sum p1 + p2
–Associate binary code: 1 with the right branch and 0 with the left branch
• Step 3: Create a unique codeword for each symbol by traversing
the tree from the root to the leaf.
–Concatenate all encountered 0s and 1s together during traversal

• The resulting tree has a prob. of 1 in its root and symbols in its
leaf node. IT 3rd year, compiled by Waggari M 19
Example
• Consider a 7-symbol alphabet given in the following
table to construct the Huffman coding.

Symbol Probability
a 0.05
• The Huffman encoding
b 0.05
algorithm picks each time two
c 0.1
symbols (with the smallest
d 0.2 frequency) to combine
e 0.3
f 0.2
g 0.1
IT 3rd year, compiled by Waggari M 20
Huffman code tree
1
0 1
0.4 0.6
0
0 1 1
0.3 e
d f 0 1
0.2
0 1
g
0.1 c
0 1
a b

• Using the Huffman coding a table can be constructed by


working down the tree, left to right. This gives the binary
equivalents for each symbol in terms of 1s and 0s.
• What is the HuffmanIT binary representation
3rd year, compiled by Waggari M for ‘café’? 21
The Shannon-Fano Encoding Algorithm
1.Calculate the frequency of each of the symbols in
the list.
2.Sort the list in (decreasing) order of frequencies.
3.Divide the list into two half’s, with the total
frequency counts of each half being as close as
possible to each other.
4.The right half is assigned a code of 1 and the left
half with a code of 0.
5.Recursively apply steps 3 and 4 to each of the
halves, until each symbol has become a
corresponding code leaf on the tree. That is, treat
IT 3rd year, compiled by Waggari M 22
each split as a list and apply splitting and code
The Shannon-Fano Encoding Algorithm
• Example: Given five symbols A to E with their frequencies being
15, 7, 6, 6 & 5; encode them using Shannon-Fano entropy
encoding
Symbol A B C D E
Count 15 7 6 6 5

0 0 1 1 1
0 1 0 1 1
0 1
Symbol Coding
A 00
B 01
C 10
D 110
E 111 IT 3rd year, compiled by Waggari M 23
Lempel-Ziv compression
•The problem with Huffman coding is that it requires
knowledge about the data before encoding takes place.
–Huffman coding requires frequencies of symbol occurrence
before codeword is assigned to symbols

•Lempel-Ziv compression:
–Not rely on previous knowledge about the data
–Rather builds this knowledge in the course of data
transmission/data storage
–Lempel-Ziv algorithm (called LZ) uses a table of code-words
created during data transmission;
•each time it replaces strings of characters with a reference to a
previous occurrence of the string.
IT 3rd year, compiled by Waggari M 25
Lempel-Ziv Compression Algorithm
Lempel-Ziv Output: there are three options in assigning a
code to each symbol in the list
• If one-symbol pattern is not in dictionary, assign (0, symbol)
• If multi-symbol pattern is not in dictionary, assign
(dictionaryPrefixIndex, lastPatternSymbol)
• If the last input symbol or the last pattern is in the dictionary,
asign (dictionaryPrefixIndex, )

IT 3rd year, compiled by Waggari M 26


Example: LZ Compression
Encode (i.e., compress) the string ABBCBCABABCAABCAAB
using the LZ algorithm.

The compressed message is: (0,A)(0,B)(2,C)(3,A)(2,A)(4,A)(6,B)


• Note: The above is just a representation, the commas and
parentheses are not transmitted
IT 3rd year, compiled by Waggari M 27
Example: Compute Number of bits transmitted
• Consider the string ABBCBCABABCAABCAAB given in example
2 (previous slide) and compute the number of bits transmitted:
Number of bits = Total No. of characters * 8 = 18 * 8 = 144 bits
• The compressed string consists of codewords and the corresponding
codeword index as shown below:
Codeword: (0, A) (0, B) (2, C) (3, A) (2, A) (4, A) (6, B)
Codeword index: 1 2 3 4 5 6 7
• Each code word consists of a character and an integer:
– The character is represented by 8 bits

Codeword (0, A) (0, B) (2, C) (3, A) (2, A) (4, A) (6, B)


Index 1 2 3 4 5 6 7
Bits: (1 + 8) + (1 + 8) + (2 + 8) + (2 + 8) + (3 + 8) + (3 + 8) + (3 + 8) = 71
bits
• The actual compressed message is: 0A0B10C11A010A100A110B
– where each character is replaced by its binary 8-bit ASCII code.

IT 3rd year, compiled by Waggari M 28


Example: Decompression
Decode (i.e., decompress) the sequence (0, A) (0, B) (2, C) (3, A)
(2, A) (4, A) (6, B)

The decompressed message is:


ABBCBCABABCAABCAAB
IT 3rd year, compiled by Waggari M 29
Exercise
Encode (i.e., compress) the following strings using the
Lempel-Ziv algorithm.

1. Aaababbbaaabaaaaaaabaabb
2. ABBCBCABABCAABCAAB
3. SATATASACITASA.

IT 3rd year, compiled by Waggari M 30

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy