You are on page 1of 18

Lossy Compression

Algorithms
•The lossless compression algorithms like Huffman
coding, dictionary based coding, arithmetic coding etc
are mainly used to compress text
•When it comes to a huge data arrangement like images,
speech, video etc., these algorithms fail to provide
sufficient compression in the data
•The term “Lossy” indicates that there is a loss of
information (mostly intentional) while encoding the data,
which is mostly unnoticeable by the human eyes
Distortion Measure
• A distortion measure is a mathematical
quantity that specifies how close is an
approximation to its original, using some
distortion criteria
• Difference between original and
approximated data?
• In Images – Perceptual distortion is
important and not the numerical distortion
Numerical distortion measures
• Mean Squared Error
σ2 = (1/N) Σn=1N (xn - yn)2
(Average Pixel Difference)

• Signal to Noise Ratio


SNR = 10 log (σx2 / σ2)
(Size of error w.r.t the Input signal)

• Peak Signal to Noise Ratio


PSNR = 10 log (xpeak2 / σ2)
(Size of error w.r.t peak value of input signal)
Rate – Distortion theory
• Lossy compression =
Trade off between
Rate and Distortion
• R specifies the rate
for given distortion
• When D = 0, the bit
rate is maximum and
follows lossless
compression
Quantization – A Basic Lossy
scheme
• Depending on whether the input is scalar
or vector, we have Scalar Quantization
(SQ) and Vector Quantization (VQ)
• When input source is uniformly distributed,
an Uniform Quantizer (UQ) can be used
Non Uniform SQ
• Here smaller step size is used where the
signal occurs predominantly and enlarged
step size is used where signal sparsely
occurs
• Two common approaches
 Lloyd Max Quantizer
 Companding
Lloyd-Max Quantizer
Begin
Choose initial level set (y0,y1)
i = 0;
Repeat
Compute bi using its equation
i=i+1
Compute yi using its equation
Untill |yi – yi-1| < ε
End
Companding
• In companded qunatization, input is
mapped by compressor function C(x)
• Then it is quantized by an uniform
quantizer
• After Transmission the quantized values
are mapped back using an expander
function C-1(x)
Vector Quantization
• Encoding of frequently occurring words in
English like “the” “or” “and” etc. provide
better compression than encoding each
letters “t” “h” “e” “a” “o” etc
• The same concept can be extended to
speech, images as segments in speech or
a collection of pixels in image and these
groups of samples are called as
VECTORS
Vector Quantization
• A compression system performs better if it
is operated in a group of vectors
(collection of data)
• VQ is same as SQ but extended to
multiple dimensions
• In VQ an n-component code vector
represents vectors that lie within a region
in n dimensional vector space. A collection
of these code vectors form the codebook
for the vector quantizer
Basic VQ procedure
Transform Coding
• In case of data like speech and images, the
different bit encoding should not be done to
highly correlated samples. But however, majority
of the samples are correlated to each other!
• Eg in text : THINK and THING, THROUGH and
THOUGH, MIGHT and FIGHT
• Transform coding helps in removal of these
correlation, so that effective encoding can be
done
Transform Coding
• Let X =[x1,x2,x3…..xk]T be vector of samples
• X -> T{x} -> Y -> T-1{x} -> X
• Y is the resultant of linear transformation of X
and vector Y’s elements are made less
correlated, so that the encoding is done better
• Less correlated = More Othogonal
• Transform T itself doesn’t compress the data, it
helps the compression algorithm to perform
better (Better compression ratio)
Discrete Cosine Transform
• Definition (DFT?)
• In Fourier Analysis, any signal can be represented in
terms of its Sine and Cosine components at various
amplitudes and freqeucies
• For instance if we take the signal as an electrical signal,
the process of determining the amplitudes of AC and DC
components of the signal is called as Cosine Transform
and in particular if the indices are integers, it is called as
DCT
• From definition if u=0, it gives the DC component and
when u=1,2… it gives the first, second… AC
components
• The IDCT is reconstruction of original signal from these
DC and AC components
DCT (Continued)
• For the 1D DCT defined, there will be a
set of 8 different basis functions and their
coefficent matrix is as shown
Characteristics of DCT
• DCT produces frequency spectrum F(u) corresponding
to the spatial signal f(i)
• The first coefficient is the DC component of the signal,
which gives the average magnitude of the signal
• The other seven AC components (basis functions) have
characteristics like the first component completes half
cycle, second completes one cycle, third completes one
and half … seventh completes three and half cycles
• DCT coefficients can also take negative values (For
image DC component is always positive)
• DCT is a linear Transformation
DCT (pA + qB) = p DCT(A) + q DCT(B)
Two Dimensional 8x8 DCT
Comparision between DCT and DFT

• The DFT coefficients will be exponential


values
• By using Euler’s formula,
eix = cos x + isin x
• We can guess that DCT is likely a
transform that forms the real part of DFT

You might also like