Dip Mod5
Dip Mod5
Module 5
IMAGE COMPRESSION
Prepared By,
Sandesha Karanth P.K & Raghavendra Katagall
Assistant Professors, Dept. Of CSE,
VCET, Puttur
[email protected], [email protected]
Image compression is the art and science of reducing amount of data required to represent
an image. Image compression is used in many applications like televideo conferencing, remote
sensing, document and medical imaging, and facsimile transmission (FAX).
M
CO
Fundamentals: P.
O
The data compression refers to the process of reducing the amount of data required to
LO
represent a given quantity of information. Here data and information are not the same, data are
TU
the mean by which information is conveyed and various amounts of data can be used to represent
.V
the same amount of information. The data can have irrelevant or repeated information are called
W
redundant data.
W
W
If we let b and b’ denote the number of bits in two representations of the same
information, the relative data redundancy R of the representation with b bits is
R = 1 – 1/C
C = b/b’
length. The 8-bit codes that are used to represent the intensities in most 2-D intensity
arrays contain more bits than are needed to represent the intensities.
2. Spatial and temporal redundancy: Because the pixels of most 2-D intensity arrays are
correlated specially,(i.e. each pixel is similar to or dependent on neighboring pixels
Information is unnecessarily replicated in the representations of the correlated pixels. In a
video sequence, temporally correlated pixels also duplicate information
3. Irrelevant information: Most 2-D intensity arrays contain information that is ignored by
human visual system and/or extraneous to the intended use of the image. It is redundant
in the sense that it is not used.
Coding Redundancy
M
Let us assume, that a discrete random variable rk in the interval [0,L-1] represent the gray
CO
level of an M x N image and that each rk occurs with probabilities pr(rk):
P.
Pr (rk) = nk / MN k=0,1,2,3…L-1.
O
LO
Where L is the number of intensity values, and nk is the number of times that the kth intensity
TU
appears in the image. If the number of bits used to represent each value of rk is l(rk), then the
.V
M
CO
Interpixel redundancy
P.
O
Interpixel redundancy is defined as failure to identify and utilize data relationships
LO
If a pixel value can be reasonably predicted from its neighboring (or preceeding / following)
TU
pixels the image is said to contain interpixel redundancy. Interpixel redundancy depends on the
.V
resolution of the image The higher the (spatial) resolution of an image, the more probable it is
W
that two neighboring pixels will depict the same object. The higher the frame rate in a video
W
stream, the more probable it is that the corresponding pixel in the following frame will depict the
W
same object these types of predictions are made more difficult by the presence of noise
M
redundancies. The operation generally is reversible and may or may not reduce directly
CO
the amount of data required to represent the image. In video applications, the mapper uses
P.
previous video frames to facilitate the removal of temporal redundancy.
O
LO
length coding scheme) and aims to reduce coding redundancies. It generates a fixed or
W
variable length code to represent the quantizer output and maps the output in accordance
W
with the code. In many cases, a variable –length code is used. The shortest code words
are assigned to the most frequently occurring quantizer output values- thus minimizing
coding redundancy.
• Future application requirements may be unknown
M
2. Code assignment: When only two symbols remain, retrace the steps in 1) and assign a
CO
code bit to the symbols in each step. Encoding and decoding is done using these
P.
codes in a lookup table manner
O
LO
TU
.V
W
W
W
The average length of this code is: Lavg = (0.4)(1) + (0.3)(3) + (0.1)(4) + (0.06)(5) + (0.04)(5)
=2.2bits/pixels
Arithmetic coding
Provides a data representation where the entire symbol sequence is encoded as a single
arithmetic code word (which is represented as an interval of real numbers between 0 and 1)
Arithmetic code construction is done in 3 steps
1. Subdivide the half-open interval [0,1) based on the probabilities of the source symbols
2. For each source symbol recursively. Narrow the interval to the sub-interval designated by
the encoded symbol. Subdivide the new interval among the source symbols based on
probability
3. Append an end-of-message indicator. Encoding is done by choosing any number in the
interval to represent the data. Decoding is done by retracing the steps in the code
construction
M
CO
P.
O
LO
size of the dictionary affects compression performance. Small dictionaries are less likely to
contain an encountered source symbol. Large dictionaries results in larger code words (lower
compression ratios)
M
CO
P.
O
LO
TU
.V
W
W
W
Run-length coding
Provides a data representation where sequences of symbol values of the same value are
coded as “run-lengths”
• 1D – the image is treated as a row-by-row array of pixels
• 2D – blocks of pixels are viewed as source symbols
Input data 222222222226666666666666699999999999999999
M
CO
P.
O
LO
TU
Figure : BMP absolute coding mode options. In this mode, the first byte of the BMP pair is 0
.V
Transform Coding
W
In transform coding a linear transform is used to map the image data into a set of
W
transform coefficients (which are then quantized and coded). For reasons of computational
W
complexity the image is subdivided into smaller subimages before the transformation
computation. The goal of the transformation process is to decorrelate (minimize the variance)
the pixels of the subimages as much as possible. This will result in a localization of the image
information in a minimal number of transform coefficients - the transformation coefficients with
little data can then be more coarsely quantized or eliminated. The better information compaction,
the better reconstruction approximations.
The following figure shows a typical block transform coding system. The decoder
implements the inverse sequence of steps of the encoder, which performs four relatively
straightforward operations: subimage decomposition, transformation, quantization, and coding.
M x N input image is subdivided first into subimages of size n X n, which are then transformed
to generate MN/n2 subimage transform arrays, each of size n X n. The quatization stage then
selectively eliminates or more coarsely quantizes the coefficients that carry the least amount of
information in a predefined sense. The encoding process terminates by coding the quantized
coefficients. Transformation coding can be
• Adaptive – each subimage is treated in an individual manner
• Non-adaptive – all subimages are treated in the same way
M
Figure : A block transform coding system i. encoder ii. Decoder.
of the subimage size. Usually a (integer power of two) size is chosen that will reduce the
TU
correlation. The following figure illustrates the graphically the impact of subimage size on
.V
transform coding reconstruction error. between adjacent subimages in the reconstructed image.
W
W
W
Bit allocation
The process of truncating, quantizing and coding the coefficients of the transformed
subimage is referred to as bit allocation. The reconstruction error in a decompressed image is a
function of
• The number of coefficients discarded
• The precision used to store the remaining coefficients
• The relative importance of these coefficients
M
images
CO
• Adaptive thresholding – the threshold value is based on the coefficients
P.
• Local thresholding – the threshold value is based on the location of the
O
LO
coeff
• N-largest – the N largest coefficients are retained (requires ordering)
TU
Note that some thresholding coding schemes result in a predefined reconstruction error rather
.V
W
Predictive coding
Provides a data representation where code words express source symbol deviations from
predicted values (usually values of neighboring pixels). Predictive coding efficiently reduces
interpixel redundancies
• 1D & 2D – pixels are predicted from neighboring pixels
• 3D – pixels are predicted between frames as well
Works well for all images with a high degree of interpixel redundancies. Works in the presence
of noise (just not as efficiently)
Input data 222222222226666666666666699999999999999999
Code 200000000004000000000000030000000000000000
Predictive coding can be used in both lossless and lossy compression schemes
M
CO
Lossless predictive coding P.
The following figure shows the basic components of lossless predictive coding system.
O
LO
The system consist of an encoder and decoder, each containing an identical predictor. As
TU
successive samples of discrete time input signal, f(n), are introduced to the encoder, the predictor
generates the anticipated value of each sample based on a specified number of past samples. The
.V
W
output of the predictor is then rounded to the nearest integer, The prediction error
W
W
The decoder shown in second part of the figure reconstruct e(n) from the received
variable-length code words and performs the inverse operation to decompress or recreate the
original input sequence.
M
of the error-free encoder, is inserted between the symbol encoder and the point at which the
CO
prediction error is formed. It maps the prediction error into a limited range of outputs, denoted
P.
e(n) , which establish the amount of compression and distortion that occurs. For a lossy
O
encoder’s predictor within the feedback loop,
LO
TU
.V
Wavelet coding
Like transform coding, wavelet coding is based on the premise that using a linear
transform (here a wavelet transform) will result in transform coefficients that can be stored more
efficiently than the pixels themselves. Due to the facts that wavelets are computationally efficient
and that the wavelet basis functions are limited in duration, subdivision of the original image is
Unnecessary. Wavelet coding typically produces a more efficient compression than DCTbased
systems
• Objectively – the mean square error of wavelet-based reconstructions are typically
lower
• Subjectively - the blocking artifacts (characteristic of DCT-based systems at high
compression ratios) are not present in wavelet reconstructions
M
The choice of wavelet to use greatly affects the compression efficiency
CO
P.
O
LO
TU
.V
W
W
M
CO
P.
O
LO
TU
.V
W
W
W