Practice Problems DIP
Practice Problems DIP
x1 1 1 1 x 2 1 0 1
T T
x3 0 1 0 x 4 1 0 0
T T
Answers
a) The mean vector of the population
1 M
m x E x x k
M k 1
b) Covariance matrix
C x E x m x x m x
T
covariance matrix for a random population
x
1 M
Cx k x kT m x m Tx
M k 1
First we calculate mxmxT
1 1 0 1
x 11 1 1 01 0 1 10 1 0 01 0 0
M
T
k x k
k 1
1 1 0 0
1 1 1 1 0 1 0 0 0 1 0 0 3 1 2
1 1 1 0 0 0 0 1 0 0 0 0 1 2 1
1 1 1 1 0 1 0 0 0 0 0 0 2 1 2
The covariance matrix is
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
c) Covariannce matrix Cy
C
Covariance matrix
m Cy for vectors y = A(x - mx), which
w are derived from x using Hotelling transform,
is a diagonaal matrix, wh
here non-zeroo cell values are the eigeenvalues of C x. Thereforee we can deffine
Cy directly using
u these eigenvalues.
e We don’t haave to calcullate the vectoor transform
ms and the mean
and the covaariance matriix for transfoormed vectorrs.
E
Eigenvalues of Cx
det(Cx - I) = 0
0.1875 0.125
5 0.125
0.1255 0.25 0 0
0.125 0 0.25
determinant is transform
med into a twoo-row form
0 .39827 0 0
Cy 0 0.25 0
0 0 23
0.0392
Haar T
Transform
m
Examplle: Calculate the Haar traansform of thhe following image:
Answeers
Givven NN imaage I, its Haaar transform iis HIHT, wheere H is an NN transform
mation matriix that shouldd
be ccomputed. H is created from
fr the Haarr functions.
Haar functionss:
H 0 (t ) 1, 0 t 1
F
Fall2017-18, DIP
P (ECE-404), C1+
+C2 Slot, VIT Unniversity Vellore, S.K. Singh (SEN
NSE)
1, 0 t 1 2
H 1 (t )
1, 1 2 t 1
p q q 0 .5
2 , t
2 p
2p
p q 0 .5 q 1
H 2 P q (t ) 2 , t p
2 p
2
0, elsewhere
The Haar functions are used to create the Haar transformation matrix as follows:
Calculate and plot the Haar functions of the continuous variable t by varying p and q.
Scale t by multiplying it by N, since an NN image needs an NN matrix.
Build entries of H from the plots of the Haar functions by taking discrete values of t: 0,1,..,N-1.
Normalize H by multiplying it by 1 N if t takes up N equally spaced discrete values.
Haar functions:
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
The Haar functions after scaling the t-axes:
Now discrete values of the Haar functions at t=0,1,2,3 (see them from the last four plots) form entries of the
transformation matrix. Thus, values of H(0,t) form the first row, values of H(1,t) form the second row,
values of H(2,t) form the third row, and values of H(3,t) form the forth row. A multiplier 1/2 appears so that
HHT=I. As a result,
1 1 1 1
1 1 1 1 1
H
2 2 2 0 0
0 0 2 2
and the solution is
1 1 1 1 0 1 1 0 1 1 2 0 2 0 0
0
1 1 1 1 1 1 0 0 1 1 1 2 0 0 0 0 0
HIH
T
4 2 2 0 0 1 0 0 1 1 1 0 2 0 0 1 1
2 2 0
1 1 0 1 1 0 1 1
0 0 0 2 0
Wavelet Analysis
A wavelet is a waveform of effectively limited duration that has an average value of zero.
It is able to perform local analysis, that is, to analyze a localized area of a larger signal. Therefore
wavelet analysis can reveal what other techniques miss, namely, breakdown points, self-similarity,
and discontinuities in higher derivatives.
It analyzes a signal at more than one resolution (multiresolution). Therefore features that might go
undetected at one resolution may be easy to capture at another.
It can compress or de-noise signals with less degradations.
Wavelet analysis is based on the lowpass and highpass filtering. A lowpass filter cuts off high frequencies
while passing low ones. A highpass filter cuts off low frequencies while passing high ones.
For many signals, the low-frequency content is the most important part, since it is what gives a signal its
identity. The high-frequency content emphasizes details.
If we simply pass a signal through each filter, this will result in twice as much data as we started with. For
example, if the original signal contains 1,000 samples, we end up with 2,000 elements!
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
A simple solution is to perform downsampling after filtering. It means throwing away every second sample
so that in total, the number of coefficients will be equal to that of samples in the signal.
Let’s call the result of lowpass filtering as the approximation and the result of highpass filtering as the detail.
Data obtained after downsampling the approximation are approximation coefficients of the wavelet
transform and data obtained after downsampling the detail are detail coefficients of the wavelet transform.
In the multistep decomposition, only the approximations are repeatedly decomposed while the details are
not!
The same procedure as described for the one-step decomposition is applied to the approximations at each
level of decomposition. For example, in order to get the decomposition at the second level, replace “Signal”
in the chain above with the “approximation coefficients” resulted from the first-level decomposition.
The course book contains very descriptive diagrams graphically depicting the 1-D and 2-D wavelet
decompositions.
To compute the wavelet transform, we need two functions: scaling and wavelet.
The scaling function is used to create a series of approximations of an image, each differing by a factor 2
from its nearest neighboring approximations. The wavelet function is then used to encode the difference in
information between adjacent approximations. The scaling function for the Haar wavelet transform and
denoted as (phi) is shown in the left figure (it is identical to the Haar function H(0,t)). The wavelet
function for the Haar wavelet transform and denoted as (psi) is shown in the right figure (it is identical to
the Haar function H(1,t)).
The wavelet function is determined by the highpass filter and associated with details, while the scaling
function is determined by the lowpass filter and associated with approximations.
The 1-D scaling function is described by the formula: j ,k ( x) 2 (2 x k ) , where (x) is the
j/2 j
scaling function, k determines integer translations along the x-axis, j determines how broad or narrow the
scaling function, and 2j/2 controls the height or amplitude of the scaling function.
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
where ( x ) 1, 0 x 1 and 0, elsewhere.
j ,k ( x) 2 j /2 (2 j x k )
where (x) is the scaling function, k determines integer translations along the x-axis, j determines how
broad or narrow the scaling function, and 2j/2 controls the height or amplitude of the scaling function.
1 0 x 0 .5
where ( x ) 1 0.5 x 1
0 elsewhere
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
The 1-D discrete wavelet transform or DWT :
1
Approximation coefficients: W ( j 0 , k )
M
f ( x)
x
j0 , k ( x)
1
Detail coefficients: W ( j 0 , k )
M
f ( x)
x
j0 , k ( x)
Therefore M=4, J=2, x=0,1,2,3, j=0,1, k=0 for j=0 and k=0,1 for j=1.
1 3
W (0,0) f ( x) 0,0 ( x) 1
2 x 0
1 3
W (0,0) f ( x) 0,0 ( x) 4
2 x 0
1 3
W (1,0) f ( x) 1,0 ( x) 1.5 2
2 x 0
1 3
W (1,1) f ( x) 1,1 ( x) 1.5 2
2 x 0
For Haar wavelets, the discretized scaling and wavelet functions correspond to the rows of the MM Haar
transformation matrix computed in the previous exercise.
For example, the values for 0 , 0 are taken from the first row of this matrix; the values for 0 , 0 are taken
from the second row of this matrix; the values for 1, 0 are taken from the third row of this matrix; the
values for 1,1 are taken from the forth row of this matrix.
Q. Compute a co-occurrence matrix for the following 5 5 image, when place operator P is
a) “one pixel to the right”
b) “one pixel to the right and one down”
1 1 1 2 2
0 1 1 2 0
2 0 0 2 1
2 2 1 1 0
1 1 0 0 2
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Answer
Co-occurrence matrix
The matrix A is defined as follows: matrix cell aij is the number of pixels having a value zj and a
neighbor having value zi in place P. The rows and columns can also be processed in different order
There can be more than one operators P. In that case we get 3 or more dimensional matrices.
1
Co-occurrence matrix is C = A , where n is the number of pixels for which P is defined.
n
a) There are three gray levels in the image: z1 = 0, z2 = 1 and z3 = 2. The matrix cell a11 is the
number 0-0 couples (zero having zero to the right) and a13 in the upper right corner is the
number of 2-0 couples (two having zero to the right)
The matrix A is
2 2 2
A 1 5 2
2 2 2
Operator P is defined for 20 pixels (the sum of elements in A) and therefore n = 20
Question:
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Q. The followinng two vecto
ors form an oorthonormal basis
b set for 1D vector off dimension 2.
1 1 1 1
,
2 1 2 1
Solutionn
F
Fall2017-18, DIP
P (ECE-404), C1+
+C2 Slot, VIT Unniversity Vellore, S.K. Singh (SEN
NSE)
Q. a. Show a block diagram for computing a 1 stage 2D subband decomposition using 1D low pass filter
hl(n) and high pass filter hh(n) to decompose an image into 4 subimages. You should only use 1D
convolution. Your block diagram should use the original image as the input, and output 4 subimages,
labeled as LL, LH, HL, and HH.
b. Show another block diagram on how to compute a 3-level wavelet transform on an image (count the
original image as level 1), where you apply the diagram you draw for (a) repeatedly.
Answer
Q. JPEG2000 achieves spatial scalability by using wavelet transform. Suppose you want to enable 3 spatial
layers, show the wavelet decomposition structure (i.e. how is the image decomposed into different
subbands) and specify which band(s) each spatial layer includes. If the original image has a size of
MxN, what is the spatial resolution of each layer?
Answer
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Answer:
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)