Ip 09
Ip 09
Coding redundancy:
We assume grey levels are random quantities.
The values of these levels are represented by suitable encoding them.
Let rk in an interval [0,1] represent the grey levels.
n
Let each rk occur with probability p r (rk ) = k , with k = 0,1,2, L − 1 where L is
n
number of grey levels.
Let l (rk ) bits be used to represent the value rk
Then average number of bits required to represent each pixel
L −1
Lavg = l ( rk ) p r ( rk )
k =0
Lavg = 2(0.19) + 2(0.25) + 2(0.21) + 3(0.16) + 4(0.08) + 5(0.06) + 6(0.03) + 6(0.02) = 2.7bits
3 1
CR = = 1.1, RD = 1 − = 0.099
2 .7 1.11
• Here coding has been used to minimize the number of symbols using variable
length coding, and code 1 has redundant code symbols. This is called removal of
coding redundancy.
• It uses the fact that generally images have regular and predictable shape and area
much large than the elements
• Hence some values are more probable than others, and they are coded with shorter
length codes.
Interpixel redundancy
A picture of 5 randomly arranged pencils, and 5 parallel pencils have the same histogram,
and same probabilities for each grey value.
However in one case, the picture shows a strong spatial correlation. Hence value of next
pixel can be predicted reasonably well. Then all values are not necessary, and many are
redundant.
These inter-pixel redundancies can be removed by using not pictorial mapping like
difference between adjacent pixels, value and length of grey level runs, etc. Usually this
leads to a non-pictorial representation.
e.g 1024 bits of binary data can be coded as
(1,63)(0,87)(1,37)(0,5)(1,4)(0,556)(1,62)(0.210) requiring 88 bits.
A complete image requires 12166 runs. 11 bits are required for each pair.
1024 × 343 × 1
Then Compression Ratio C R = = 2.63 , and R D = 0.62
12166 × 11
Psycho visual Redundancy:
The eye and the brain do not respond to all visual information with same sensitivity.
Some information is neglected during the processing by the brain. Elimination of this
information does not affect the interpretation of the image by the brain.
Edges and textural regions are interpreted as important features and the brain groups and
correlates such grouping to produce its perception of an object.
Psycho visual redundancy is distinctly vision related, and its elimination does result in
loss of information. Quantization is an 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.
IGS Quantization:
The graininess from quantization can be reduced by Improved Grey Scale quantization
which breaks up the edges and contours and makes them less apparent. IGS adds a
pseudo random number generated from low order bits of neighboring pixels to each pixel
before quantizing them. If most significant bits are all 1, the 0s are added. The msbs
become the coded value.
Fidelity criteria:
Objective:
Let the pixel error be given as e( x, y ) = fˆ ( x, y ) − f ( x, y ) .
Then total error between two images
M −1 N −1
[ fˆ ( x, y) − f ( x, y)]
x =0 y =0
erms = ˆ [
f ( x, y ) − f ( x, y ) ]
MN x =0 y =0
The mean square SNR is
M −1 N −1
[ fˆ ( x, y)]
2
x =0 y =0
SNRms = M −1 N −1
[ fˆ ( x, y) − f ( x, y)]
2
x =0 y =0
The three redundancy removal methods are typically combined to get maximum
compression.
Input image goes into an encoder which creates a set of symbols. It consists of a source
encoder and a channel encoder.
After transmission through the channel it goes into a decoder, consisting of channel
decoder and source decoder from which the reconstructed image is given out.
The source encoder removes most of the redundancies, and the channel encoder increases
noise immunity.
The two distinct coding processes are reversed at the respective decoders at the receiver.
If the channel has no noise, channel encoder-decoder may be omitted.
The source encoder starts with a mapper transforming data into a non visual format
reducing interpixel redundancies. (i.e. run length encoding).
This is followed by a quantizer (psycho visual redundancy removal) and a symbol
encoder generates variable of fixed length code to minimize coding redundancy.
At the receiver input, symbol decoder is followed by an inverse mapper. (de-quantization
cannot be done, hence there is no de-quantizer block )
If the parity word c 4 c 2 c1 is non zero, its value indicates location of the erroneous bit,
which is inverted to correct the error. The correct binary word is then given by
h3 h5 h6 h7 , and thus a single error is corrected.
More errors can be corrected by defining more redundant bits, making channel encoded
word longer (This moves away from out intended compression and instead increases the
data length. For this reason longer hamming codes are not preferred.)
Information Theory
Entropy:
Information is modeled as a probabilistic process.
If an event E occurs with probability P(E) it contains
1
I ( E ) = log = − log P ( E ) units of information called self information of E.
P( E )
When the base of the log is 2, unit of information is a bit.
Assume the source produces random sequence of symbols from a finite set of source
alphabet A given by {a1 , a 2 , , a j }.
[ ]T
Let probability of a j be P (a j ) and let a vector z = P(a1 ),P(a 2 ), ,P(a j ) give the set of
probabilities of alphabet symbols.
The finite ensemble ( A, z ) then describes the source completely.
The self information in a j is
I (a j ) = − log P(a j )
If a large number k symbols are generated, a j will occur kP(a j ) times, contributing
information − kP(a j ) log P (a j )
Thus all the k symbols give information:
j
− k P (a j ) log P (a j ) ,
j =1
The average information per symbol is defined as the Entropy of the source, and is given
by
j
H ( z ) = − P (a j ) log P (a j )
j =1
The finite ensemble (B, v ) then describes the received information completely.
P (bk ) is related to P (a j ) by
J
P (bk ) = P (bk a j )P (a j )
j =1
Properties of n-tuples:
Source output now has J n = M possible n element sequences α m called block variables.
A new dictionary now consists of a set A′ of n element sequences with
A′ = {α 1 , α 2 , , α M } and P (α i ) = P(a j1 ) P(a j 2 ) P (a jn )
Also,
z ′ = {P (α 1 ), P (α 2 ), P (α M )}
Hence the corresponding entropy is
M
H ( z ) = − P(α i ) log P(α i )
′
i =1
And also it follows that H ( z ′) = nH ( z )
Or
M
H ( z ′) ≤ Lavg ′ < H ( z ′) + 1 where Lavg ′ = P(α i )l (α i )
i =1
Dividing by n,
′
Lavg 1
H (z) ≤ < H (z ) +
n n
In the limit as n becomes large, this becomes
′
Lavg
lim = H (z )
n→∞
n
The Shannon’s first theorem states that:
′
Lavg
it is possible to make the ratio approach arbitrarily close to H(z) by coding
n
infinitely long extensions of the source.
H (z )
The coding efficiency can be now defined as η = n ,
′
Lavg
In the ideal case efficiency becomes 1 as n becomes infinite.
For any R < C where C is the capacity of a zero memory channel with channel matrix
Q , there exists an integer r and a code of block length r and rate R such that the
probability of a block decoding error is less than or equal to an arbitrary value ε for
ε > 0. .
This implies that probability of error in the noisy channel can be made arbitrarily small,
as long as coded message rate is less than the channel capacity.
Huffman Coding:
Removes coding redundancy by using a variable length coding procedure.
Symbols are arranged in order of decreasing probabilities, and probabililty values are
stated alongside.
The symbols with two smallest probabilities are (considered as) combined
the probability table is reordered using the combined value.
The smallest two probabilities in the new table are combined, and table again reordered.
This continues till only two probability values remain.
These are assigned code values 0 and 1.
Each coded probability value is examined to determine its original constituents, and if it
is a combination 0 and 1 code digits are added to make the code assignment unique.
This is repeated backwards till all original probability values have associated code words.
This procedure creates a near optimal code, and generates a look up table for subsequent
coding requirements. The code is an instantaneous (no references to previous procedures
are required for decoding) uniquely decodable, variable length block code. (see example)
P(a1) = 0.1, P(a2) = 0.4, P(a3) = 0.06, P(a4) = 0.1, P(a5) = 0.04, P(a6) = 0.3
The coding method is difficult to apply when there are large number of symbols to be
coded. In such a case, truncated Huffman, B2, binary shift, Huffman shift and other
computationally more efficient codes are used with some sacrifice in average length.
For details of these codes, refer to the text book.
# ) ".# 1!!.
""0(/ 23
• , (-. !#/
• # !.'
• 0
"
1
•
• % +!# "
•
•
456 6 # ) "/# 1!!.
"10"@ 3
456
•
• 7
•
•
• 456 89)# 9))# 2:)
• ; ;
• ) ' # 1./
!#"# 1## 1..
• 7 #
9
# # ;1..1..; 1./#
• # 1./#
1..1..#
• 9 <# ."1 # ' = '
<
• $ ? "
? ; % ;
? ; % ;
• #
% # " 1
A #
• 9 #
%
#
% #
% %
1
•
BB
C
• 1
• " # 5
! #
"
• $ ! "
•
• "1@ "1' D # @ ! "
# 8 "1@ "1' ""!!!!!! !"!!!!!!#
•
• E "7 ,7
• 9 % > #
• C # #
• " !#
1 "! ""
• " 1
•
6 # ) "/# 1!!.
"0"1 3
,
•
• )>
• F
• ,7 "7
• 0
"
1 # !
• %
• C 6
• ) # D D#
D
• # *!
$
• #
•
9 G F
• 9 # #
# #
• ) # F #
• F #
+
>>> > ) '"@H
• # $ %% & ! ' 2:J
• D
7# ;
• 7 D #
• & ( )
• 7# ; 7# 7;
• * L & C&
* !!"
•
) ! "# !!! """
• 2
"(
• 8 # +
# N O P
• N7
%
• F
1(# '#
• %
'"
• - ) ) # . /
% & (
. 2
O R R S !
4 2 # 3 !'# 1!!.
(0!/ 23
• 0 ))&)) $
• ( %
• # #
• #
• T
•
(</ /'" -
• ) # 2
•
9
(!0" 9 "!0" 1!0"
4 # 3 !'# 1!!.
B0!. 23
•
7
% #
• 3& !& :3 %
• %# % "
:3 " -
• 6 ζ 7 # )&
$& 6 ζ # !& )
• % #
% %
, 2 # 3 !'# 1!!.
B0(. 23
• % 7
• %% & !&) !& :23
• , %
• : $ # % #
%
•
•
• )
)! &$&) % %
• % ) #
% )"
• 9 % % %
#
0
• )"
#
• %
• & % #
%
• # #
%
•
• : :) 6*
• N4# 9 %
• N4 N4 #
• 9 6* *
• :) :
N4
• * :#
• 9 #
# % & 7 %
• 6 :) % # 8
#
• D
• : # 1
• E D
1
• F
• #
• 9 # , # ' &
# ) &
• # % #
&&
5 # 3 !'# 1!!.
/0B1 23
5
• 6, "
# # 3
• % %
# %
)
• 9 # # 9
# %
%
0
•
• C
8! $"! $" ":#
) ) & )7
1
• 6
% % #
• ": ,7
% #
"#
• U 9 # 6& )
#
•
#
%
• 89! $" % 89! # 5
%
• % P2$8 #
2 )
C & # 3 "@# 1!!.
/0"< 3
,
•
• 1: 9 8 ( B
% & &
• ) & )< #
• /B 1 "#
: A I '
1
• B 4&C
, ": % %
• ) : N# + 4&C
+ 4&C "
• ) <# 4&C !""" " !""!#
:23 : "!"!""!