Image Compression
DATA COMPRESSION
1. Data compression is an art or science of representing
information in a compact form.
2. We create these compact representations by identifying
& using structures that exist in the data.
3. Data can be characters in a text file, numbers that are
samples of speech or image waveforms or sequences of
numbers that are generated by other processes.
WHAT IS DATA COMPRESSION
• A data compression program is used to convert
data from an easy-to-use format to one optimized
for compactness.
• Compression Purposes:
1. Save storage space
2. Reduce communication capacity requirement
DATA COMPRESSION STRATEGIES
•Data Compression Strategies
•Lossless Compression
•Lossy Compression
Lossless Compression
• A lossless technique means that the restored data
file is identical to the original.
• This is absolutely necessary for many types of
data, for example: executable code, word
processing files, tabulated numbers, etc.
• Different techniques for lossless compression are:
1. Run-length Encoder Technique
2. Huffman Encoding
3. Delta Encoding
Run-length Encoder Technique
Run-length encoding is a simple method of
compressing data files which frequently contain
the same character repeated many times in a row.
Disadvantage
• If the average run-length is longer than two,
compression will take place.
• Otherwise the encoding data length is become
quite more than of original text.
Huffman Encoding
• This method is named after D.A. Huffman, who
developed the procedure in the 1950s.
• More than 96% of this file consists of only 31
characters: the lower case letters, the space, the
comma, the period, and the carriage return.
• We will assign each of these 31 common
characters a five bit binary code: 00000 = "a",
00001 = "b", 00010 = "c", etc. This allows 96% of
the file to be reduced in size by 5/8.
Contd……
• The five bit codes, 11111, will be a flag indicating
that the character being transmitted is not one of
the 31 common characters.
• The next eight bits in the file indicate what the
character is, according to the standard ASCII
assignment. This results in 4% of the characters in
the input file requiring 5+8=13 bits.
• The idea is to assign frequently used characters
fewer bits and seldom used characters more bits.
Example of Huffman Encoding
Implementation
• To implement Huffman or arithmetic encoding,
the compression and un-compression algorithms
must agree on the binary codes used to represent
each character (or groups of characters). This can
be handled in one of two ways.
• Use a predefined encoding table
• Use encoding optimized for the particular data
being used.
In Min variance Huffman code, variation in codelength is
less as compared to standard Huffman code.
Delta Encoding
Delta encoding can be used for data
compression when the values in the original
data are smooth, that is, there is typically only a
small change between adjacent values.
Example
It is very common when the file represents a signal.
Lossy Compression
• All real world measurements inherently contain a
certain amount of noise.
• If the changes made to these signals resemble a
small amount of additional noise, no harm is done.
Compression techniques that allow this type of
degradation are called lossy.
• Lossy techniques are much more effective at
compression than lossless methods. The higher the
compression ratio, the more noise added to the
data.
Lossy Compression Techniques
• Two most common and widely used technique for
image and video compression are:-
1. JPEG Image Compression
2. MPEG Video Compression
JPEG Image Compression
• JPEG is named after its origin, the Joint
Photographers Experts Group.
• Best example of transform compression is JPEG
standard.
• Transform compression is based on a simple
premise: when the signal is passed through the
Fourier (or other) transform, the resulting data
values will no longer be equal in their information
carrying roles.
JPEG Image Compression Method
• JPEG compression starts by breaking the image
into 8×8 pixel groups.
• Each pixel is a single byte, a grayscale value
between 0 and 255.
• Each group is initially represented by 64 bytes.
After transforming and removing data, each group
is represented by, say, 2 to 20 bytes.
JPEG Image Un-compression Method
• During un-compression, the inverse transform is taken of
the 2 to 20 bytes to create an approximation of the original
8×8 group.
• These approximated groups are then fitted together to form
the uncompressed image.
• Fourier transform is easy to use, but does not provide
adequate compression so we use Discrete Cosine
Transform (DCT).
• Fourier transform uses sine and cosine waves to represent a
signal, but the DCT only uses cosine waves.
Effects Of Compression Ratio