Unit 1
Unit 1
without degrading image quality below an acceptable threshold. By reducing the file size,
more images can be stored in a given amount of disk or memory space.
Types of Compression:
Lossless compression algorithms reduce the size of files without losing any information in
the file, which means that we can reconstruct the original data from the compressed file.
Lossy compression algorithms reduce the size of files by discarding the less important
information in a file, which can significantly reduce file size but also affect file quality.
Lossy compression is the method which While Lossless Compression does not
1. eliminate the data which is not eliminate the data which is not
noticeable. noticeable.
In Lossy compression, A file does not While in Lossless Compression, A file can
2.
restore or rebuilt in its original form. be restored in its original form.
Lossy compression reduces the size of But Lossless Compression does not
4.
data. reduce the size of data.
:
Methods used for Lossy and Lossless compression
Algorithms used in Lossy compression are:
Transform coding,
Lempel-Ziv-Welch,
Huffman Coding,
Output:
6A 5B 8C 2D 5E 3F
2. Encode WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW
Output
12W 1B 12W 3B 24W 1B 14W
DICTIONARY-BASED ALGORITHMS
The compression techniques we have seen so far replace individual symbols with a variable length
codewords. In dictionary compression, variable length substrings are replaced by short, possibly even
fixed length codewords. Compression is achieved by replacing long strings with shorter codewords
• The text is encoded by replacing each phrase Ti with a code that acts as a pointer to the dictionary.
Encode “TOBEORNOTTOBEORTOBEORNOT#”
There are 26 symbols in the plaintext alphabet (the capital letters A through Z). # is used to
represent a stop code
The initial dictionary, then, consists of the following
entries:
Symbol Decimal Symbol Decimal
# 0 N 14
A 1 O 15
B 2 P 16
C 3 Q 17
D 4 R 18
E 5 S 19
F 6 T 20
G 7 U 21
H 8 V 22
I 9 W 23
J 10 X 24
K 11 Y 25
L 12 Z 26
M 13
OUTPUT:
Extended
Dictionary
CODE Description
27 TO 20 CODE OF FIRST LETTER T
28 OB 15 CODE OF FIRST LETTER O
29 BE 2 CODE OF FIRST LETTER B
30 EO 5 CODE OF FIRST LETTER E
31 OR 15 CODE OF FIRST LETTER O
32 RN 18 CODE OF FIRST LETTER R
33 NO 14 CODE OF FIRST LETTER N
34 OT 15 CODE OF FIRST LETTER O
35 TT 20 CODE OF FIRST LETTER T
36 TOB 27 CODE OF FIRST TWO LETTERS TO
37 BEO 29 CODE OF FIRST TWO LETTERS BE
38 ORT 31 CODE OF FIRST TWO LETTERS OR
39 TOBE 36 CODE OF FIRST TWO LETTERS TOB
40 EOR 30 CODE OF FIRST TWO LETTERS EO
41 RNO 18 CODE OF FIRST TWO LETTERS RN
42 O# 15 CODE OF FIRST LETTER O