Sunteți pe pagina 1din 24

Image Compression

Lecture 9
Sankalp Kallakuri
elsanky@gmail.com
Arithmetic Coding
• The arithmetic codes do not generate block codes.
• There is no one to one correspondence between the
code word and the sequence of symbols.
• A random number selected from an interval is used to
depict a symbol.
• The length of the symbol decides the interval length.

1 0.2 0.08 0.072 0.0688


a4 a4
0.6752
a3 a3 a3

a2 a2

0 a1 0 0.04 0.056 0.0624


Arithmetic Coding

• The 3 decimal places are used to code the


sequence.

• 3/5 0.6 decimal digits / source.

• Bounds set by the noiseless coding theorem not


met due to message ending symbols getting
added.

• Scaling and rounding.


LZW Coding
• Exploits interpixel redundancy and does not require
priory knowledge of the probability.

• It assigns fixed length codes to variable length symbol


sequences.

• It is a dictionary based code. For an L bit data source


with 2L possible symbols the first 2L symbols are allotted
codes [0-2L].

• Beyond which a dictionary word is allotted to the symbol


sequences.
LZW Coding

• Each entry in the dictionary is a code word for a


recognized symbol sequence.

• The decoder creates a dictionary as it parses the coded


sequence.

• A problem with the practical implementation is dictionary


overflow.

• Usually the dictionary is flushed and reinitialized.

• The compression ratio could be used as a threshold to


reinitialize the dictionary.
Example: LZW Coding
TOBEORNOTTOBEORTOBEORNOT#
Bit-Plane Coding
• The Bit planes of an image can be coded in order to
exploit interpixel redundancy.

• Using gray code instead of binary code is a way to


reduce the number of 0-1/1-0 transitions in adjacent
pixels with adjacent pixel values.

• The higher order bit planes tend to have less


randomness as compared to the lower bit planes.

• Each of the bit planes could be compressed individually


by binary compression methods.
Constant Area Coding

• Areas of constant white or black are identified and


assigned code words.
• The regions with mixed intensities are also identified and
are appended with a prefix.
• The most probable of the region is assigned a one bit
code ‘1’ the other two categories are given two bit codes
‘10’ and ‘11’.
White Block Skipping
• Useful while compressing text.

• Solid white blocks are ‘0’ black and other blocks are
coded by ‘1’ followed by a bit pattern.

• There are slight variations in which the solid white lines


are coded as ‘0’ and mixed or black with ‘1’ as a prefix.

• 2D sub-blocks could be created an treated in a similar


fashion. Completely white sub-blocks are coded with ‘0’.

• Iteratively the sub-blocks get coded.


One Dimensional run-length coding

• The sequences of ones and zeros are encoded as runs


[the lengths of the sequences] .

• Used in Fax.

• The common way to denote the runs


1) is to give the value of the first run at every line
2) assume the first run is white and the length could be
be zero.
One Dimensional Run Length Coding

• The variable length codes are usually used with the run length
codes to further compress the data.

• Symbol aj is used to represent a black run length code of length j.

• The probability of such a run could be calculated as [runs of size j] /


[all runs].

• The entropy of the runs can be obtained from the probabilities.

• The entropy of the run lengths is given by


H 0  H1
H RL 
L0  L1
2D Run Length Coding

• Relative Address Coding tracks the binary transitions.


ec – distance between consecutive transitions on the
same line [current line]
cc’- distance between transitions of same type on
consecutive lines [previous line]
c’ cc’

ec
e c
Contour Tracing and Coding
• Direct Contour Tracing

• Predictive Differential Quantizing

• Front and back contour are coded as differences in the start


points on adjacent scan lines as well as the differences in
lengths of the segment enclosed by the contour.

• Start and end messages are needed to signal the starting and
ending [merge] points on the contours.

d1

d2
Transform Coding

• The spatial domain is converted to a transform domain


• Followed by quantization in the transform domain.

Input Compressed
Image Construct Symbol image
Forward Quantizer
NxN nxn Encoder
Transform
subimages

Compressed Symbol Inverse Merge Decompressed


image
decoder transform nxn image
subimages
Transform Coding

• The image is divided into smaller subimages.

• The subimages are transformed into a transform domain.


DFT and DCT are among the common transforms.

• Each transformed subimage has the coefficients with the


least information is quantized away.

• The quantized coefficients are then run length coded.

• The local characteristics of the image can be used to


vary the quantization adaptively.
Transform Selection

• Some useful properties that transforms


may have when used for compression are
1) separability
2) symmetry
3) energy compaction.
4) fast transforms
5) variance of the transform coefficents
6) decorrelation
Transforms for Compression
DFT
Has a fast transform.

Can be implemented with circular convolution.

Separable Symmetric and Periodic.

Needs image sizes to be padded to powers of 2.

Needs complex arithmetic.

DCT
Fast.

Has very high energy compaction for correlated data.


Fourier Transform Kernel
The matrix elements of the Fourier Transform
Discrete Cosine Transform Kernel

Kernel elements of Discrete Cosine Transform


Hadamard Transform Kernel
Walsh Transform

The walsh transform is obtainable from the Hadamard transform


by bit reversal permutation followed by gray code permutations.
Basis Functions

Walsh basis functions DCT Basis Functions


Bit Allocation

The process of transforming and truncating and encoding


is called bit allocation.

Two kinds of quantizations are called Thresholding and Zonal encoding.

Thresholding is a coarse quantization of the coefficients on the basis


of magnitude.

Zonal Coding finds the regions or coefficients with the maximum


Variance or information and keeps them while discarding the low entropy
zones.

The Zonal quantised coefiecients are coded in two possible ways


1) same number of bits/coeff – normalized by standard deviations and
uniformly quantized.
Bit Allocation

2) fixed No. of bits distributed unequally- the coefficents are modeled as


rayleigh, gaussian , laplacian and the bits
allocated depend on the standard deviation.

Threshold Coding uses a mask to quantize the coefficients with lower


magnitudes away. The coefficients that are retained are coded out of
sequence.

Different ways of thresholding are


1) to apply a global threshold
2) to vary the threshold over the different positions of coefficients.
3) N largest coefficients are retained .

S-ar putea să vă placă și