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

Unit 7-Image Data Compression

Image compression is the process of reducing the amount of data required to represent an image, which facilitates easier storage and transmission. It involves various techniques to eliminate redundant data, including spatial, temporal, coding, inter-pixel, and psycho-visual redundancies, and can be classified into lossy and lossless compression methods. The document also discusses the importance of fidelity in compression, detailing objective and subjective criteria for measuring the quality of compressed images.

Uploaded by

gipalaj384
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Unit 7-Image Data Compression

Image compression is the process of reducing the amount of data required to represent an image, which facilitates easier storage and transmission. It involves various techniques to eliminate redundant data, including spatial, temporal, coding, inter-pixel, and psycho-visual redundancies, and can be classified into lossy and lossless compression methods. The document also discusses the importance of fidelity in compression, detailing objective and subjective criteria for measuring the quality of compressed images.

Uploaded by

gipalaj384
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 54

Image Data

Compression
What is Image Compression ?

Image compression is the process of reducing the


amount of data required to represent an image
Image Compression

Image compression provides ease of storage and transmission


Some basic example of Image
Compresssion
Uncompressed original data 
BBBBBBBBBAAAAAAAAAAAAAAANMMMMMMMMMM
Compressed data  B09A16N01M10

Image
10 10 20
20 20 20 Compressed data  10032006
20 20 10
Compression Fundamentals
• Image compression involves reducing the size of image data files, while
retaining necessary information

• Retaining necessary information depends on the applications

Compression Ratio =
Compression can be achieved because we
have a lot of redundant data in any information

DATA = INFORMATION + REDUNDANT DATA


Data Redundancy
• no relevant information
• repetitive data

Compression has a goal to reduce the amount of data by reducing the


amount of redundancy

Resolution or Features should be unchanged for human perception


Types of Redundancy in any video /
image
• Spatial redundancy
• Temporal redundancy
Spatial Redundancy
• Spatial redundancy is present in areas of images or video frames
where
• pixel values vary by small amounts
• Pixel values are duplicated within a structure,
• Example : In the image shown in figure, spatial
redundancy is present in parts of the background, and
in skin areas such as the shoulder.

Data Compression algorithm explores such


redundancy within an image
Temporal Redundancy
• Temporal redundancy is present in video signals when there is significant
similarity between successive video frames.
• Figure shows two successive frames from a video sequence. It is clear that the
difference between the two frames is small, indicating that it would be
inefficient to simply compress a video signal as a series of images.

Temporal explores redundancy between


successive image frames
Basic Data Redundancies

• Coding redundancy
• Inter-pixel redundancy
• Pyscho-visual redundancy
Coding Redundancy
• Information is always represented in different forms of codes
• There are many coding techniques which convert an information into a code
• Coding techniques assigns a unique code to the symbols of message / pixels
of image
• Wrong choice of coding technique creates unnecessary additional bits
• The extra bits are called redundancy
• Coding redundancy is caused due to poor selection of coding technique
Inter-pixel Redundancies
• Neighboring pixels in the same image are correlated (not
statistically independent)
• Inter-pixel correlation is called as inter-pixel spatial redundancy
• Inter-pixel redundancy in successive frames of a video is called
inter-pixel temporal redundancy
• The visual contribution of a single pixel is redundant and can be
guessed from the values of its neighbors

Example :
• Consider an image with a constant background
• The visual nature of the image background is given by many pixels
that are not actually necessary
Psycho-visual Redundancy
• Pyscho-visual redundancy is related to vision
• The eye and the brain do not respond to all visual information with same
sensitivity
• The human eye cannot see all the grey levels
• Eliminating such grey levels do not affect the interpretation of the image by
the brain
• Psycho-visual redundancy deals with the information which is psycho-visually
(pyscho-acoustic) redundant based on human perception
• Information that is not perceived by human senses (seen or heard) can be
removed to achieve compression
• Example: When 256 levels are reduced by grouping to 16 levels, objects are
still recognizable. The compression is 2:1, but an objectionable graininess and
contouring effect results
Psycho-visual Redundancy
• If the image will be used for visual observation (i.e illustration on the web, etc)
• A lot of information is psycho-visually redundant.
• It can be removed without changing the visual quality of the image
• This kind of compression is irreversible
Fidelity
• The degree of exactness with which the data is reproduced
• Fidelity criterion is used to determine important information to be
retained when compressing files.
• Fidelity criteria is divided into 2 classes :
i. Objective fidelity criteria
ii. Subjective fidelity criteria
Objective Fidelity Criteria
• Objective fidelity criteria measures amount of error in decompressed
image.
• The smaller the value of error, the better is the quality of compressed
image
Distortion Measures/Error Metrics/
Objective Fidelity Criteria
• Errors are measured using:
1. Mean – Square - Error
2. Signal to Noise ratio (SNR)
3. Peak Signal to Noise ratio
Mean Square Error (MSE)
• Mean Square Error (MSE) for two dimensional data (eg image)
• For input image , f(x,y) and Reconstructed image of size M x N
Root Mean Square Error (RMSE)
Signal to Noise Ratio (SNR)
𝑆𝑖𝑛𝑎𝑙 𝑃𝑜𝑤𝑒𝑟 𝑃 𝑠
𝑆𝑁𝑅= =
𝑁𝑜𝑖𝑠𝑒 𝑃𝑜𝑤𝑒𝑟 𝑃 𝑛
For input image , f(x,y)

[∑ ∑ ]
𝑀− 1 𝑁 −1
1
Signal Power = 𝑓 2 (𝑥 , 𝑦 )
𝑀×𝑁 𝑥=0 𝑦= 0

Reconstructed image ,

Noise Power (MSE) =


Peak Signal to Noise Ratio

2
255
𝑃𝑆𝑁𝑅=10 𝑙𝑜𝑔10
𝑀𝑆𝐸
Subjective Fidelity Criteria
Example
• 2x2 original image and reconstructed image is as given. Find RMSE

Original Reconstructed
5 4 4 4
2 3 1 2
General Image Compression Models
𝑓 (𝑥 , 𝑦) Source Channel Source
Channel ^𝑓 ( 𝑥 , 𝑦)
Channel
Encoder Encoder decoder decoder

Removes input Increases noise Inverse Inverse operation


Transmitting operation of
redundancy immunity encoded image of source encoder
channel encoder

• The source encoder is responsible for removing redundancy (coding, inter-pixel, pyscho-visual)
and outputs a set of symbols
• The channel encoder improves the noise immunity of the output of source encoder.
• Channel encoder ensures robustness against channel noise
• The job of channel decoder and source decoders is to get back the original signal.
• Run length coding is used to eliminate or reduce interpixel redundancies.
• Huffman encoding is used to eliminate or reduce coding redundancies
General Image Compression Models
• Compression has two types i.e. Lossy and Lossless technique.
• A typical image compression system comprises of two main blocks
• An Encoder (Compressor) and Decoder (Decompressor).
• The image f(x,y) is fed to the encoder which encodes the image so as
to make it suitable for transmission.
• The decoder receives this transmitted signal and reconstructs the
output image f(x,y).
• If the system is an error free one f(x,y) will be a replica of f(x,y).
Classification of data compression
techniques
X Y
Compression
Xc Reconstruction
Algorithm Algorithm

X=Y X≠Y
Lossless Data Compression

• In lossless data compression, the integrity of the data is


preserved.
• The original data and the data after compression and
decompression are exactly the same because, for the
methods under this subcategory, the compression and
decompression algorithms are exact inverses of each other
• No part of the data is lost in the process
Lossy Data Compression
• In lossy data compression, the loss of some fidelity is
acceptable.
• The Lossy technique is a data compression method which
compresses data by discarding (losing) some of it.
• The procedure aims to minimize the amount of data that needs
to be handled, and/or transmitted by a computer.
Lossy Compression Lossless Compression
Lossy compression is the method which eliminate the data While Lossless Compression does not eliminate the data
which is not noticeable. which is not noticeable.
Reconstructed data is not same as the original data Reconstructed data same as original data.
In Lossy compression, A file does not restore or rebuilt in its While in Lossless Compression, A file can be restored in its
original form. original form.
In Lossy compression, some amount of original data is lost, In lossless Compression Original, data is not lost, hence
hence, data quality is compromised. does not compromise the data’s quality.
Provides Less compression as compared to lossy.
Better compression as compared to lossless compression.
Lossless Compression does not reduce the size of data as
Lossy compression reduces the size of data.
compared to Lossy compression .
Algorithms used in Lossy compression are: Transform coding, Algorithms used in Lossless compression are:
Discrete Cosine Transform, Discrete Wavelet Transform, Run Length Encoding, Lempel-Ziv-Welch, Huffman Coding,
fractal compression etc. Arithmetic encoding etc.
Lossy compression is used in Images, audio, video. Lossless Compression is used in Text, images, sound.
Lossless Compression has less data-holding capacity than
Lossy compression has more data-holding capacity.
Lossy compression technique.
Lossy compression is also termed as irreversible compression. Lossless Compression is also termed as reversible compression
Lossless (Error free) compression
techniques
• Two types
1. Dictionary based technique
2. Statistical based technique
Dictionary based
lossless compression technique
• In many applications images consists of recurring patterns.
• Most of the background information in images is a set of
pixels which have a specific pattern
• A very efficient approach to encode these images is to
keep a list, DICIONARY, of frequently-occurring patterns.
• When these patterns appear they are encoded with a
reference to the dictionary
• What we are actually doing is splitting up the image pixels
into two classed – frequently occurring patterns and
infrequently occurring patterns
Example of Dictionary based coding
• Run length coding

• Consider the first row of image has following grey values


2 2 2 5 5 5 5 5 5 6 6 6 6 2 2 2 5 5 5 5 5 5 6 6 6 6
• • • • • • • • • • • • •
• • • • • • • • • • • • •
2, 3 5, 6 6, 4
• • • • • • • • • • • • •
• • • • • • • • • • • • • The first code specifies the grey value, followed by the
length of run
• • • • • • • • • • • • •
• • • • • • • • • • • • • Hence, the RLE of the first row is simply  235664
• • • • • • • • • • • • •
RLE achieves considerable compaction of images which
have a fairly constant background.

The RLE eliminates inter-pixel redundancies


Drawback of RLE
• At times RLE , double the size of the file

• Example : Perform RLE on following data


1 2 5 3 12

RLE code  11215131121

The RLE code is double than that of original sequence.


Hence RLE should be used only if we have the same grey value repeated
many times
Statistical method of
lossless compression technique
• HUFFMAN CODING :

• Huffman encoding is a lossless statistical method


• Characters that occur most often (high probability) are assigned few bits
• While characters that occur rarely (low probability) are assigned more bits

In other words, characters with high probability (frequency) will be coded with
shorter code than characters with small probability
Steps of Huffman coding
1. for the given grey levels, write down the list of probabilities
2. Sort the list in descending order
3. Add the smallest (last) two probabilities
4. Again sort the probabilities and repest the process until just one
value is left
Compute the Huffman code for the given data
{1,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,6,6,7}

si ni Pi = ni / Total count
si Pi
1 7 7/28 = 0.25 1 0.25
2 6 6/28 = 0.21 2 0.21
3 5 5/28=0.18 3 0.18
4 4 4/28=0.14
4 0.14
5 3 3/28=0.11
5 0.11
6 2 2/28=0.07
6 0.07
7 1 1/28=0.04
7 0.04
Total
count
= 28
si Pi Place in
Pi Pi
descending Pi Pi
order 0.57
0.25 0.32 0.43
1 0.25 0.25 0.43
0.32 1
2 0.21 0.21 0.22 0.25
0.21 0.21 0.25 0.57
3 0.18 0.18
4 0.14 0.14 0.18 0.22 0.43
5 0.11 0.11 0.14 0.32

6 0.07 0.07 0.22


7 0.04 0.04 0.11 1

0.43
0.57
0.22 0.21
0.32 0.25
0.11 0.11
0.18 0.14

0.07 0.04
1
1 0
0.43
0.57 1 0
1 0 0.22 0.21 (2)
1
0.32
0 0.25 (1) 1 0
0.11 (5) 0.11
0.18 (3) 0.14 (4) 1 0
0.07 (6) 0.04 (7)
0

si Huffman code
1 10
2 00
Final Huffman code 3 111
table for each symbol / 4 110
pixel value
5 011
6 0101
7 0100
Example 2
Compute the Huffman code for the given data
{a,a,a,a,a,a,b,b,b,c,c,c,c,c,c,d,d,d,d,d,d,d,d,d,d,e,e,e,e,f,f}

si ni Pi = ni / Total count
a 6 6/31 = 0.193 si Pi
b 3 3/31 = 0.096 a 0.193
c 6 6/31=0.193 b 0.096
d 10 10/31=0.323 c 0.193
e 4 4/31=0.129
d 0.323
f 2 2/31=0.065
e 0.129
Total
count f 0.065
= 31
Pi Pi
si Pi Place in
Pi Pi 0.61
descendi 0.386
0.323 0.386 1
ng order 0.323 0.323
0.193 0.29 0.29 0.61
a 0.193 0.323
0.193 0.193
b 0.096 0.193 0.386
0.161 0.193
c 0.193 0.193
0.129 0.29
d 0.323 0.129
e 0.129 0.096
f 0.065 0.065 0.161
1

0.386
0.61

0.193 0.193
0.323 0.29

0.161 0.129

0.096 0.065
1
1 0
0.386
0.61 1 0
1 0
0.193 0.193
0.323 0.29 (a) (c)
(d)
1 0
0.161 0.129
1 0
(e)
0.096 0.065
(b) (f)
si Hamming code

a 01
b 1011
c 00
d 11
e 100
f 1010
Image compression standards
Lossy Compression
• Many methods of lossy compression have been developed.
• However, a family of techniques known as TRANSFORM CODING has
proven to be most valuable
Transform Coding method of
Lossy Compression
• We transform the image using some transformation
• Discard the pixels coefficients that are nearly zero
• When these images are reconstructed using inverse transform, we get
compressed image in which little information is lost.

• We have learnt Lossy compression using DCT thoroughly in IMAGE


TRANSFORM kindly revisit the slides
Image Compression Standards-
Continuous Tone images
• JPEG (Joint Photographic Expert Group (JPEG)’s is the fist standard most
widely used to compress and code continuous tone monochrome and color
images of any size and sampling rate.

• JPEG is very simple and easy to use standard that is based on the Discrete
Cosine Transform (DCT)
JPEG
• JPEG is a sophisticated lossy/lossless compression method for color or grayscale
still images (not movies).
• It does not handle bi-level (black and white) images very well.
• It also works best on continuous-tone images, where adjacent pixels have
similar colors.
• One advantage of JPEG is the use of many parameters, allowing the user to adjust
• amount of the data lost (and thus also the compression ratio) over a very wide
range
• Often, the eye cannot see any image degradation even at compression ratios of
10:1 or 20:1.
• There are two main modes:
• lossy (also called baseline) and lossless (which typically produces compression
ratios of around 0)
• Most implementations support just the lossy mode
Image Compression for Binary
image

• A binary image is one that consists of pixels that can have one of exactly two colors,
usually black and white.
• Binary images are also called bi-level
• This means that each pixel is stored as a single bit—i.e., a 0 or 1.
• A binary image can be stored in memory as a bitmap, a packed array of bits.
• A 640×480 image requires 37.5 KB of storage.
• Because of the small size of the image files, fax machine and document management
solutions usually use this format.
• Most binary images also compress well with simple run-length compression
schemes.
Example
• Consider the below 7 x 8 binary image .
• To store this we require 56 bytes

• If we apply run length coding


3W1B3W  6 bytes

2W1B1W1B2W  10 bytes
1W1B3W1B1W  10 bytes
8B  2 bytes

3W1B3W  6 bytes
Total bytes after run length
3W1B3W  6 bytes coding : 52 bytes
3W1B3W  6 bytes

3W1B3W  6 bytes

You might also like