0% found this document useful (0 votes)
40 views18 pages

Practice Problems DIP

The document provides sample vectors and asks to calculate the mean vector, covariance matrix, and covariance matrix for transformed vectors using the Hotelling transform. The mean vector is calculated as the average of the sample vectors. The covariance matrix is calculated by taking the difference of each vector from the mean, multiplying the differences, and averaging. For the transformed vectors, the covariance matrix is a diagonal matrix with the eigenvalues of the original covariance matrix along the diagonal. No further calculations are needed since the transform preserves eigenvalues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views18 pages

Practice Problems DIP

The document provides sample vectors and asks to calculate the mean vector, covariance matrix, and covariance matrix for transformed vectors using the Hotelling transform. The mean vector is calculated as the average of the sample vectors. The covariance matrix is calculated by taking the difference of each vector from the mean, multiplying the differences, and averaging. For the transformed vectors, the covariance matrix is a diagonal matrix with the eigenvalues of the original covariance matrix along the diagonal. No further calculations are needed since the transform preserves eigenvalues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Tutorials

Q. The following sample vectors have been extracted from an image.

x1  1 1 1 x 2  1 0 1
T T

x3  0 1 0 x 4  1 0 0
T T

These vectors can be considered to be a random vector population


a) Calculate the mean vector of the population
b) Calculate the covariance matrix
c) How would you calculate the covariance matrix for vectors y, when y is derived from x using
Hotelling-transform?

Answers
a) The mean vector of the population

1 M
m x  E x   x k
M k 1

 1 1 0 1  0.75


1         
  1  0  1  0    0.5 
4 
 1 1 0 0   0.5 

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

0.75 0.5625 0.375 0.375


m x m   0.5 0.75 0.5 0.5   0.375 0.25 0.25 
 T
x

 0.5   0.375 0.25 0.25 
and then the sum part

1 1 0  1 
 x   11 1 1  01 0 1  10 1 0  01 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

3 1 2 0.5625 0.375 0.375  0.1875  0.125 0.125


1
C x  1 2 1    0.375 0.25 0.25    0.125 0.25 0 
4
2 1 2  0.375 0.25 0.25   0.125 0 0.25 

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.125 0.25   0.1875    0.1225


0.125  (0.25   ) 0
0.12
25 0  0.12
25 0.25  

0.125(0.125  0.03125)  (0.25   )(2  0.43


375  0.03 125)  0
we get a thirrd order equaation, which has to be sollved
-3 + 0.6875 2 – 0.125  + 0.00390
0625 = 0
 1 = 0.399827, 2 = 0.25, 3 = 0.03923
when we put the eigenvaalues in the m
matrix we geet the covariaance matrix

0 .39827 0 0 

Cy   0 0.25 0 
 0 0 23
0.0392

Notice that Cy has the saame eigenvallues as Cx.

Haar T
Transform
m
Examplle: Calculate the Haar traansform of thhe following image:

Answeers
Givven NN imaage I, its Haaar transform iis HIHT, wheere H is an NN 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


where p=1,2,3,… and q=0,1,…,2p-1.

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 NN image needs an NN 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.

What can wavelet analysis do?

 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.

One-step wavelet decomposition can be represented by the following chains:

Signal  Lowpass Filtering  Downsampling 


approximation coefficients

Signal  Highpass Filtering  Downsampling 


det ail coefficients

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.

Several 1-D Haar scaling functions are given below.

Fall2017-18, DIP (ECE-404), C1+C2 Slot, VIT University Vellore, S.K. Singh (SENSE)
where  ( x )  1, 0  x  1 and 0, elsewhere.

The 1-D wavelet function is described by the formula:

 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.

Several 1-D Haar wavelet functions are given below.

 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)

M=2J, x=0,1,…,M-1, j=0,1,…,J-1, k=0,1,…,2j-1 and J is the number of scales.

Example: Let f(0)=1, f(1)=4, f(2)=-3, f(3)=0.

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.

The DWT is computed as follows:

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 MM 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

0.10 0.10 0.10


1
C A  0.05 0.25 0.10
20
0.10 0.10 0.10
b) Now P is defined differently.
1 2 3 
A  2 2 2
0 3 1 
Now P is defined for 16 pixels

0.0625 0.1250 0.1875


1
C A  0.1250 0.1250 0.1250
16
0.0000 0.1875 0.0625

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

a. Use thesse 1D bases to


t construct a 2D orthono ormal transfo
orm basis sett. Write dowwn the 4 basiss
images.
b. Apply your
y 2 image, and find all thee transform coefficients.
2D transsform to the ffollowing 2 c
8 8 
F 
4 4

c. Quantizee the transforrm coefficiennts with a un


niform quantiizer with a sttepsize of q==3. For the DC
D
coefficieent, you shouuld assume thhe minimal possible
p valu
ue is 0. That iis, values in [0,q) is
quantizeed to q/2. Butt for AC coeffficients, you
u should assu
ume the quanntizer is sym mmetric, i.e.
values inn [-q/2, q/2) is
i quantized to 0. Write down
d the quaantized coeffficients.
c. Determiine the recon nstructed imaage from the quantized cooefficients.

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)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy