DIP Endsem Answer Key
DIP Endsem Answer Key
Q.1. Write a MATLAB program to create a black grid over a grayscale image. [10]
Q.2. [5+5]
Q.3. (a) Imagine a 64 x 64 image with 2 bits/pixel representation. The normalized gray levels are 0, 1/3,
2/3, 1. Suppose the image distribution is given by Table-Q3a.
(i) Apply histogram equalization and draw the equalized histogram. [5]
rk 0 1 2 3
p(rk) 0 0.44 0.37 0.19
(ii) Apply Huffman encoding on original image to determine variable length codes for each gray level.
Calculate the entropy and compression ratio achieved. [5]
(b) Use Run-Length Encoding to encode the MSB plane of following 4-bit image Fig-Q3b: [5]
0 0 1 1
0 1 1 1
0 1 1 1
0 0 1 1
Run length code = 2, 2, 1, 3, 1, 3, 2, 2 (as Runs of 0’s) [Other RLE forms are accepted]
Q.4. Given a 10x10 size binary image, whose central 4 x 4 pixels are all 1 and others are 0. Calculate the
gradients of this image using the Sobel operators Hy. Show all the (actual) pixel values. [5]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 3 4 4 3 1 0 0
0 0 1 3 4 4 3 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 -1 -3 -4 -4 -3 -1 0 0
0 0 -1 -3 -4 -4 -3 -1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Q.5. (a) For the following sample vectors: x1 = (4,11)T, x2 = (8,4)T, x3 = (13,5)T and x4 = (7,14)T.
(i) Calculate the mean vector (mX) and Covariance matrix (CX). [5]
4 −11
mx = (8,8.5)T , CX = [ ]
−11 23
(ii) Calculate vectors y, where y is derived from x using Hotelling-transform. [5]
0.5574 −0.8303
A=[ ]
0.8303 0.5574
Using y = A(x-mx), each y vector can be calculated.
λ1 0 30.3849 0
CY =[ ]= [ ] (from eigenvalues)
0 λ2 0 6.6151
(b) Calculate the Euler number for the following images: [5]
(i) E = 3-3 = 0 (ii) E = 8-12+2 = -2
Q. 6. (b) For the triangle shape boundary as shown in Fig. Q6 and given three boundary points:
(i) Find the Fourier descriptors (FD) with starting point as O. [5]
(ii) State and verify the FD’s translation property for the translation with ∆xy = 1+2j. [5]
(b) Perform Region (or hole) filling operation on a binary image and write the first four
intermediate images (X1, X2, X3 X4) [5]