0% found this document useful (0 votes)
31 views4 pages

Unit 1

The document discusses different types of image compression including lossless and lossy compression. Lossy compression reduces file sizes by discarding unimportant data while lossless compression does not lose any information. Common lossy algorithms are JPEG and MP3 while common lossless algorithms are PNG and FLAC. The document compares the advantages and disadvantages of each type.

Uploaded by

mohamadi_r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

Unit 1

The document discusses different types of image compression including lossless and lossy compression. Lossy compression reduces file sizes by discarding unimportant data while lossless compression does not lose any information. Common lossy algorithms are JPEG and MP3 while common lossless algorithms are PNG and FLAC. The document compares the advantages and disadvantages of each type.

Uploaded by

mohamadi_r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Image compression is a process applied to a graphics file to minimize its size in bytes

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:

There are two types of compression: lossless and lossy.

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.

Difference between Lossy and Lossless Comparison

S.NO Lossy Compression Lossless Compression

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.

In Lossy compression, Data’s quality is But Lossless Compression does not


3.
compromised. compromise the data’s quality.

Lossy compression reduces the size of But Lossless Compression does not
4.
data. reduce the size of data.

Algorithms used in Lossy compression Algorithms used


are: Transform coding, Discrete Cosine in Lossless compression are: Run Length
5.
Transform, Discrete Wavelet Transform, Encoding, Lempel-Ziv-Welch, Huffman
fractal compression etc. Coding, Arithmetic encoding etc.

Lossy compression is used in Images, Lossless Compression is used in Text,


6.
audio, video. images, sound.

Lossless Compression has less data-


Lossy compression has more data-
7. holding capacity than Lossy compression
holding capacity.
technique.

Lossy compression is also termed as Lossless Compression is also termed as


8.
irreversible compression. reversible compression.
Advantages and Disadvantages of Lossy and Lossless comparison:
Lossy Lossless
Small file sizes. Ideal for web
Pros use. Lots of tools, plugins and No loss in quality. Slight decreases in file sizes.
software support it.

Quality degrades due to higher


Cons Compressed files are larger than lossy files.
rate of compression.

:
Methods used for Lossy and Lossless compression
Algorithms used in Lossy compression are:

Transform coding,

Discrete Cosine Transform,

Discrete Wavelet Transform,

fractal compression etc.

Algorithms used in Lossless compression are:

Run Length Encoding,

Lempel-Ziv-Welch,

Huffman Coding,

Arithmetic encoding etc

Run Length Encoding

Run-length encoding (RLE) is a form of lossless compression.. RLE is a simple method of


compressing data by specifying the number of times a character or pixel colour repeats followed
by the value of the character or pixel. The aim is to reduce the number of bits used to represent
a set of data.

1. Encode AAAAAABBBBBCCCCCCCCDDEEEEEFFF using RLE

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 general scheme is as follows:

• The dictionary D is a collection of strings

. For completeness, the dictionary includes all single symbols.

• The text T is parsed into a sequence of phrases: T = T1T2 . . . Tz,

• The text is encoded by replacing each phrase Ti with a code that acts as a pointer to the dictionary.

LEMPEL ZIV WELCH

Use the LZW algorithm to compress the string: BABAABAAA


The steps involved are systematically shown in the diagram below.

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

You might also like