0% found this document useful (0 votes)
19 views27 pages

Compression Huff Merged

The document discusses image compression, explaining its purpose of reducing data size while retaining necessary information, and the importance of compression in storage and transmission. It covers various compression methods, including lossless and lossy techniques, and introduces Huffman coding as a specific algorithm for data compression. Additionally, it highlights the trade-offs between quality and compression, as well as the advantages and disadvantages of different methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views27 pages

Compression Huff Merged

The document discusses image compression, explaining its purpose of reducing data size while retaining necessary information, and the importance of compression in storage and transmission. It covers various compression methods, including lossless and lossy techniques, and introduces Huffman coding as a specific algorithm for data compression. Additionally, it highlights the trade-offs between quality and compression, as well as the advantages and disadvantages of different methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Any Differences?

Image Compression.

JPEG

Size-270 KB Size-22 KB

“Without Compression a C D store only 200 Pictures or 8


Seconds Movie”

Lecture by Kalyan Acrjya


What is Image Compression?

⚫ Image compression is the process of reducing


the amount of data required to represent an
image.

Original Image Decoded Image


Bitstream

Encoder 0101100111... Decoder


Why Compression?
7

Storage

Ease of Transmission
Compression Fundamentals

✓ Image compression involves reducing the size of image


data files, while retaining necessary information

✓ Retaining necessary information depends upon the


application

✓ Image segmentation methods, which are primarily a data


reduction process, can be used for compression

✓ The ratio of the original, uncompressed image file and the


compressed file is referred to as the compression ratio
Why Compression?

✓ Now, consider the transmission of video images, where we need


multiple frames per second, If we consider just one second of video
data that has been digitized at 640x480 pixels per frame, and requiring
15 frames per second for interlaced video, then:
✓ Waiting 35 seconds for one second’s worth of video is not exactly real
time.

✓ Even attempting to transmit uncompressed video over the highest


speed Internet connection is impractical
Image Compression General Models
10

Source Channel
F(x, y) Encoder Encoder
Channel/
Store

Source Channel
F’(x, y)
Decoder Decoder

⚫ Some image Compression Standard

▪ JPEG-Based on DCT

▪ JPEG 2000-Based on DWT

▪ GIF-Graphics Interchange Format etc.

Lecture by Kalyan Acharjya


Data ≠ Information

⚫ Data and information are not synonymous terms.

⚫ Data is the means by which information is conveyed.


⚫ Data compression aims to reduce the amount of data required
to represent a given quantity of information while preserving
as much information as possible.
⚫ Image compression is an irreversible proce
Image Compression

Lecture by Kalyan Acharjya 15


Trade Off: Quality vs. Compression

⚫ Lossless Compression (Information Preserving) -


Original can be recovered exactly. Higher quality,
bigger.
⚫ Lossy Compression- Only an approximation of
the original can be recovered. Lower quality,
smaller.
Some Basic Compression Methods

⚫ Huffman coding
⚫ Arithmetic Coding
⚫ Run Length Coding
Huffman Coding
35

Lecture by Kalyan Acharjya


Huffman Coding
36

Efficiency=H/Lavg x 100 %
Algorithm
Presentation
z

Topic : Huffman Coding


Algorithm
Presentation
z

Topic : Huffman Coding


z
Contents

▪ Definition

▪ Simulation

▪ Application

▪ Advantage/Disadvantage
z

Definition
▪ Huffman Coding is a lossless data compression
algorithm. The idea is to assign variable-length codes
to input characters, lengths of the assigned codes are
based on the frequencies of corresponding
characters.

▪ The most frequent character gets the smallest code


and the least frequent character gets the largest
code.
z Message- BCCABBDDAECCBBAEDDCC
Length-20
Letter ASCII Binary In Electric components the alphabet is
Code Form sent through ASCII code . The ASCII
A 65 01000001 code letter capital A is 65 and we need 8
bis binary to convert 65.
B 66 01000010

C 67 01000011
• For 1 Letter We need 8 bits
D 68 01000100
• For 20 Letters We need 8×20=160 bits
E 69 01000101
z
Simulation
Message : BCCABBDDAECCBBAEDDCC

Letter Count

First of all place the counts in A 3


increasing order then take
minimum and add them now the B 5
root node of letter E and A is 5
C 6

D 4

E 2
5

E-2 A-3 D-4 B-5 C-6


z
Simulation
Message : BCCABBDDAECCBBAEDDCC

A 3
Then between the root node 5
and counts take the minimum
B 5
and add them up . Here 5 and 4
are minimum so we add them
C 6
and make 9 as root node so
9 continue the process.
D 4

E 2
5

E-2 A-3 D-4 B-5 C-6


z
Simulation
Message : BCCABBDDAECCBBAEDDCC

A 3
20
B 5

C 6

9 D 4

11 E 2
5

E-2 A-3 D-4 B-5 C-6


z
Simulation
Message : BCCABBDDAECCBBAEDDCC

Mark the left hand edges as 0 and right


20 hand edges as 1 and then traverse from
root node to any letter . Suppose we
0 want to go A from root node so the
distance will be 001, for B 10 and so on.
1
9
0

11
5 1
0 0 1
1

E-2 A-3 D-4 B-5 C-6


z
Simulation
Message : BCCABBDDAECCBBAEDDCC A 001

B 10

For A we need 3 C 11
20
bits ,B 2 bits , C 2
0 bits , D 2 bits, E 3 D 01
bits
1
E 000
9
0 For A,
Count =3
11 So total bits 3*3=9 bits
5 1 And so on
0 0 1
1

E-2 A-3 D-4 B-5 C-6


z
Simulation
Message : BCCABBDDAECCBBAEDDCC

A 3 001 3×3=9

B 5 10 5×2=10
20
0 C 6 11 6×2=12
1
D 4 01 4×2=8
9
0
E 2 000 2×3=6
11
5 1 Total=45 bits
0 0 1
1 As we see first we do need 160
bits and now we need 45 bits
now we have compressed the
E-2 A-3 D-4 B-5 C-6
cost and size.
z Application
Generic File Compression:
❖ Files: GZIP, BZIP, 7Z
❖ Archives : 7z
❖ File System : NTFS,FS+,ZFS

Multimedia :
❖ Image : GIF, ZPEG
❖ Sound : Mp3
❖ Video : MPEG, HDTV

Communication :
❖ ITU-T T4 Group 3 Fax
❖ V.42 Bis modem
❖ Skype

Databases : Google,Facebook,…
z
Advantages/Disadvantages
Advantages :
The Huffman Coding has the minimum average length.
Easy to implement and fast.

Disadvantages :
Requires two passes over the two input (one to compute frequencies, one for
coding),thus encoding is slow.
Requires storing the Huffman codes(or at least character frequencies)in the
encoded file, thus reducing the compression benefit obtained by encoding.
z

Thank You

You might also like