









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This solution manual is for problems related Digital Image processing course. This was recommended by Prof. Anwar Malik at Bengal Engineering and Science University. It includes: Geodesic, Dilation, Complement, Noise, Spikes, Amplitude, Shape, Element, Image, Border, Pixel
Typology: Exercises
1 / 15
This page cannot be seen from the preview
Don't miss anything!










Figure P9.
The second step follows from the definition of geodesic dilation. The third step follows from the fact that the point-wise minimum of two sets of numbers is the negative of the point-wise maximum of the two numbers. The fourth and fifth steps follow from the definition of the complement. The sixth step follows from the duality of dilation and erosion (we used the given fact that ˆb = b ). The last step follows from the definition of geodesic erosion.
The next step in the iteration, D( g^2 )
f
, would involve the geodesic dilation of size 1 of the preceding result. But that result is simply a set, so we could obtain it in terms of erosion. That is, we would complement the result just mentioned, complement g , compute the geodesic erosion of the two, and complement the result. Continuing in this manner we conclude that
D( gn )(f ) =
E ( g^1 c)
E ( gn c^ −^1 )
f c^ #c .
The other property is proved in a similar way.
(a) The noise spikes are of the general form shown in Fig. P9.35(a), with other possibilities in between. The amplitude is irrelevant in this case; only the shape of the noise spikes is of interest. To remove these spikes we perform an opening with a cylindrical structuring element of radius greater than Rmax , as shown in Fig. P9.35(b). Note that the shape of the structuring element is matched to the known shape of the noise spikes.
(a) Color the image border pixels the same color as the particles (white). Call the resulting set of border pixels B. Apply the connected component algorithm (Section 9.5.3). All connected components that contain elements from B are particles that have merged with the border of the image.
Figure P10.
Edges and their profiles
Gradient images and their profiles Figure P10.
(a) The first row in Fig. P10.5 shows a step, ramp, and edge image, and horizontal profiles through their centers. Similarly, the second row shows the correspond- ing gradient images and horizontal profiles through their centers. The thin dark borders in the images are included for clarity in defining the borders of the im- ages; they are not part of the image data.
Figure P10.7 shows the solution.
Figure P10.
Consider first the Sobel masks of Figs. 10.14 and 10.15. A simple way to prove that these masks give isotropic results for edge segments oriented at multiples of 45◦^ is to obtain the mask responses for the four general edge segments shown in Fig. P10.9, which are oriented at increments of 45◦. The objective is to show that the responses of the Sobel masks are indistinguishable for these four edges. That this is the case is evident from Table P10.9, which shows the response of each Sobel mask to the four general edge segments. We see that in each case the response of the mask that matches the edge direction is ( 4 a − 4 b ), and the response of the corresponding orthogonal mask is 0. The response of the re- maining two masks is either ( 3 a − 3 b ) or ( 3 b − 3 a ). The sign difference is not significant because the gradient is computed by either squaring or taking the absolute value of the mask responses. The same line of reasoning applies to the Prewitt masks.
is thus given by
∂ f¯ /∂ x =
n^2
z (^) i ∈S (^) x +1,y
z (^) i −
n^2
z (^) i ∈S (^) x y
z (^) i
The first summation on the right can be interpreted as consisting of all the pixels in the second summation minus the pixels in the first row of the mask, plus the row picked up by the mask as it moved from (x , y ) to (x + 1, y ). Thus, we can write the preceding equation as
∂ f¯ /∂ x =
n^2
z (^) i ∈S (^) x +1,y
z (^) i −
n^2
z (^) i ∈S (^) x y
z (^) i
n^2
z (^) i ∈S (^) x y
z (^) i
n^2
(sum of pixels in new row)
n^2 (sum of pixels in 1st row)
n^2
z (^) i ∈S (^) x y
z (^) i
n^2
y +∑ n^ − 21
k =y − n^ − 21
f (x + n + 1 2
, k ) −
n^2
y +∑ n− 21
k =y − n− 21
f (x − n − 1 2
, k )
n^2
' (^) y +∑ n^ − 21
k =y − n^ − 21
f (x +
n + 1 2 , k ) − f (x −
n − 1 2 , k )
This expression gives the value of ∂ f¯ /∂ x at coordinates (x , y ) of the smoothed image. Similarly,
∂ f¯ /∂ y =
n^2
z (^) i ∈S (^) x ,y + 1
z (^) i −
n^2
z (^) i ∈S (^) x y
z (^) i
n^2
z (^) i ∈S (^) x y
z (^) i
n^2 (sum of pixels in new col)
n^2 (sum of pixels in 1st col)
n^2
z (^) i ∈S (^) x y
z (^) i
n^2
x +∑ n^ − 21
k =x − n^ − 21
f (k , y +
n + 1 2
n^2
x +∑ n− 21
k =x − n− 21
f (k , y −
n − 1 2
n^2
' (^) x +∑ n^ − 21
k =x − n^ − 21
f (k , y + n + 1 2
) − f (k , y − n − 1 2
The edge magnitude image corresponding to the smoothed image f¯ (x , y ) is then given by M¯ (x , y ) =
( ∂ f¯ /∂ x )^2 + ( ∂ f¯ /∂ y )^2.
(a) We proceeed as follows
Average ∇^2 G (x , y ) =
−∞
−∞
∇^2 G (x , y )d x d y
−∞
−∞
x 2 + y 2 − 2 σ^2 σ^4
e −^
x 2 +y 2 2 σ^2 d x d y
σ^4
−∞
x 2 e −^
x 2 2 σ^2 d x
−∞
e −^
y 2 2 σ^2 d y
σ^4
−∞
y 2 e −^
y 2 2 σ^2 d y
−∞
e −^
x 2 2 σ^2 d x
σ^2
−∞
e −^
x 2 +y 2 2 σ^2 d x d y
σ^4
2 πσ × σ^2
2 πσ
σ^4
2 πσ × σ^2
2 πσ
2 πσ^2
σ^2 = 4 π − 4 π = 0 the fourth line follows from the fact that
variance(z ) = σ^2 =
2 πσ
−∞
z 2 e −^
z 2 2 σ^2 d z
and 1 2 πσ
−∞
e −^
z 2 2 σ^2 d z = 1.
(b) The answer is yes for functions that meet certain mild conditions, and if the zero crossing method is based on rotational operators like the LoG func-
Using the definition of the Laplacian operator we can express this equation as
g (x , y ) =
∂ x 2
∂ y 2
∂ x 2
∂ y 2
where the second step follows from Problem 10.18, with G (x ) = e −^
x 2 2 σ^2 and G (y ) =
e −^
y 2 2 σ^2. The terms inside the two brackets are the same, so only two convolutions are required to implement them. Using the definitions in Section 10.2.1, the partials may be written as
∂^2 f ∂ x 2
= f (x + 1 ) + f (x − 1 ) − 2 f (x )
and ∂^2 f ∂ y 2 = f (y + 1 ) + f (y − 1 ) − 2 f (y ).
The first term can be implemented via convolution with a 1 × 3 mask having coefficients coefficients, [ 1 − 2 1], and the second with a 3 × 1 mask having the same coefficients. Letting ∇^2 x and ∇^2 y represent these two operator masks, we have the final result:
which requires a total of four different 1-D convolution operations.
(b) If we use the algorithm as stated in the book, convolving an M × N image with an n × n mask will require n^2 × M × N multiplications (see the solution to Problem 10.18). Then convolution with a 3 × 3 Laplacian mask will add another 9 × M × N multiplications for a total of (n^2 + 9 ) × M × N multiplications. De- composing a 2-D convolution into 1-D passes requires 2nM N multiplications, as indicated in the solution to Problem 10.18. Two more convolutions of the re- sulting image with the 3×1 and 1×3 derivative masks adds 3M N + 3 M N = 6 M N multiplications. The computational advantage is then
(n^2 + 9 )M N 2 nM N + 6 M N
n^2 + 9 2 n + 6
which is independent of image size. For example, for n = 25, A = 11.32, so it takes on the order of 11 times more multiplications if direct 2-D convolution is used.
Parts (a) through (c) are shown in rows 2 through 4 of Fig. P10.21.
(b) θ = cot−^1 ( 2 ) = 26.6◦^ and ρ = ( 1 ) sin θ = 0.45.
(a) Point 1 has coordinates x = 0 and y = 0. Substituting into Eq. (10.2-38) yields ρ = 0, which, in a plot of ρ vs. θ , is a straight line.
(b) Only the origin (0, 0) would yield this result. (c) At θ = + 90 ◦, it follows from Eq. (10.2-38) that x · ( 0 ) + y · ( 1 ) = ρ , or y = ρ. At θ = − 90 ◦^ , x · ( 0 ) + y · (− 1 ) = ρ , or −y = ρ. Thus the reflective adjacency.
The essence of the algorithm is to compute at each step the mean value, m 1 , of all pixels whose intensities are less than or equal to the previous threshold and, similarly, the mean value, m 2 , of all pixels with values that exceed the threshold. Let p (^) i = n (^) i / n denote the i th component of the image histogram, where n (^) i is the number of pixels with intensity i , and n is the total number of pixels in the image. Valid values of i are in the range 0 ≤ i ≤ L − 1, where L is the number on intensities and i is an integer. The means can be computed at any step k of the algorithm:
m 1 (k ) =
I (∑k − 1 )
i = 0
i p (^) i /P(k )
where
P(k ) =
I (∑k − 1 )
i = 0
p (^) i
and
m 2 (k ) =
i =I (k − 1 )+ 1
i p (^) i /[ 1 − P(k )].
The term I (k − 1 ) is the smallest integer less than or equal to T (k − 1 ), and T ( 0 ) is given. The next value of the threshold is then
T (k + 1 ) =
[m 1 (k^ ) +^ m 2 (k^ )]^.
Intensities^ T k ( ) used to compute m k 2 ( + 1)
Intensities used to compute m k 1 ( + 1)
Intensity
Histogram values
0 L - 1
Figure P10.
In case (2), when the threshold value moves to the left, m 2 will decrease or stay the same and m 1 will also decrease or stay the same (the fact that m 1 decreases or stays the same is not necessarily obvious. If you don’t see it, draw a simple his- togram and convince yourself that it does), depending on how much the thresh- old moved and on the values of the histogram. However, neither threshold can increase. If neither mean changes, then T (k + 2 ) will equal T (k + 1 ) and the algo- rithm will stop. If either (or both) mean decreases, then T (k + 2 ) < T (k + 1 ), and the new threshold moves further to the left. This will cause the conditions just stated to happen again, so the conclusion is that if the thresholds starts mov- ing left, it will always move left, and the algorithm will eventually stop with a value T > 0, which we know is the lower bound for T. Because the threshold al- ways decreases or stops changing, no oscillations are possible, so the algorithm is guaranteed to converge.
Case (3) causes the threshold to move the right. An argument similar to the preceding discussion establishes that if the threshold starts moving to the right it will either converge or continue moving to the right and will stop eventually with a value less than L−1. Because the threshold always increases or stops changing, no oscillations are possible, so the algorithm is guaranteed to converge.
Intensity
Histogram values
(^0) L /2 L - 1 Intensities of background
Intensities of objects
I min } } M
Figure P10.
The value of the the threshold at convergence is independent of the initial value if the initial value of the threshold is chosen between the minimum and max- imum intensity of the image (we know from Problem 10.27 that the algorithm converges under this condition). The final threshold is not independent of the initial value chosen for T if that value does not satisfy this condition. For ex- ample, consider an image with the histogram in Fig. P10.29. Suppose that we select the initial threshold T ( 1 ) = 0. Then, at the next iterative step, m 2 ( 2 ) = 0, m 1 ( 2 ) = M , and T ( 2 ) = M / 2. Because m 2 ( 2 ) = 0, it follows that m 2 ( 3 ) = 0, m 1 ( 3 ) = M , and T ( 3 ) = T ( 2 ) = M / 2. Any following iterations will yield the same result, so the algorithm converges with the wrong value of threshold. If we had started with Imin < T ( 1 ) < Imax , the algorithm would have converged properly.
(a) For a uniform histogram, we can view the intensity levels as points of unit mass along the intensity axis of the histogram. Any values m 1 (k ) and m 2 (k ) are the means of the two groups of intensity values G 1 and G 2. Because the his- togram is uniform, these are the centers of mass of G 1 and G 2. We know from the solution of Problem 10.27 that if T starts moving to the right, it will always move in that direction, or stop. The same holds true for movement to the left. Now, assume that T (k ) has arrived at the center of mass (average intensity). Because all points have equal "weight" (remember the histogram is uniform), if T (k + 1 ) moves to the right G 2 will pick up, say, Q new points. But G 1 will lose the same number of points, so the sum m 1 + m 2 will be the same and the algorithm will stop.