You are on page 1of 6

521467S Digital Image Processing

Answers to Exercise 1.
1. Bits per frame nb = 24 1920 1080 = 49766400 bits/frame. Total number of frames nf = 24 frames/s(60602) s = 172800 frames. One gigabyte is 8 10243 bits. Video size is s = nb nf bits 49766400 172800 = GB 8 10243 = 1001.13 GB. Almost one terabyte is needed to store the video without compression. 2. (a) 4-connectivity. First scan: The image is scanned from left to right and from top to bottom. We examine every pixel P and the pixels from left (x1 ) and up (x2 ). x1 Actions to be taken: If P = 0, continue to next position If P = 1 and both x1 and x2 are 0, give a new label to P only one of the neighbors (x1 or x2 ) is 1, give P the same label that the neighbor has both x1 are x2 are 1 and x1 and x2 have same labels, give that label to P x1 and x2 have dierent labels, give one of them to P and mark the labels equal After this scan the given binary image looks like following (labels a, b, c, . . ., are used) 0 0 0 0 0 0 0 0 0 0 c c c 0 0 0 0 a c c c c 0 0 0 a c c c c c 0 0 0 c 0 0 0 0 0 0 b 0 d d d d 0 0 b b 0 d d d 0 0 0 0 0 a=c 0 0 0 0 x2 P

Second scan: The image is scanned and pixels are given nal labels according to the equivalences found during the rst scan. 1

In our example we notice that a and c are equal. They are given nal label A. Pixels labelled with b and d are given nal labels B and C respectively on the second scan. 0 0 0 0 0 0 0 0 0 0 A A A 0 0 0 0 A A A A A 0 0 0 A A A A A A 0 0 0 A 0 0 0 0 0 0 B 0 C C C C 0 0 B B 0 C C C 0 0 0 0 0 0 0 0 0

There are three 4-connected components in the picture. (b) 8-connectivity. The picture is scanned in the similar way as with 4-connectivity, but now we examine four neighbors of P (also the diagonal neighbors). x2 x1 After the rst scan: 0 0 0 0 0 0 0 0 0 0 a a a 0 0 0 0 a a a a a 0 0 0 a a a a a a 0 0 0 a 0 0 0 0 0 0 b 0 a a a a 0 0 b b 0 a a a 0 0 0 0 0 a=b 0 0 0 0 x3 P x4

We notice that a is equal to b. They are given nal label A in the second scan. 0 0 0 0 0 0 0 0 3. (a) 0 0 A A A 0 0 0 0 A A A A A 0 0 0 A A A A A A 0 0 0 A 0 0 0 0 0 0 A 0 A A A A 0 0 A A 0 A A A 0 0 0 0 0 0 0 0 0

i. There is no 4-path between p and q , as none of the 4-neighbors of pixel q have values from V .

ii. The shortest 8-path from p to q is p = (3, 0); (3, 1); (2, 2); (1, 2); (0, 3) = q The length of a digital path is N 1 where N is the number of pixels on the path. Thus, the length of the shortest path is 4. iii. The shortest m-path from p to q is p = (3, 0); (3, 1); (3, 2); (2, 2); (1, 2); (0, 3) = q The length of this path is 5. (b) i. One possibility for 4-path from p to q is p = (3, 0); (2, 0); (2, 1); (2, 2); (2, 3); (1, 3); (0, 3) = q The length of this path is 6. It is easily veried that another 4-path of the same length exists between p and q . ii. One possibility for the shortest 8-path from p to q is p = (3, 0); (2, 1); (1, 1); (0, 2); (0, 3) = q The length of the shortest path is 4. iii. The shortest m-path from p to q is p = (3, 0); (2, 0); (2, 1); (1, 1); (0, 1); (0, 2); (0, 3) = q The length of this path is 6. Notice that this path is not unique. 4. (a) The transformation that does equalization of an image histogram is the cumulative density function. To compute that, we rst need to calculate the probability pk for each gray level in the original picture rk nk pk 0 400 .098 1/7 700 .171 2/7 800 .195 3/7 900 .220 4/7 500 .122 5/7 400 .098 6/7 196 .048 7/7 200 .048

Now we compute the discrete cumulative density function sk . rk pk sk 0 .098 .098 1/7 .171 .269 2/7 .195 .464 3/7 .220 .684 4/7 .122 .806 5/7 .098 .904 6/7 .048 .952 7/7 .048 1

Finally, to get the discrete gray transformation, the CDF is rounded to the nearest discrete value available. 3

rk sk

0 .098 1/7

1/7 .269 2/7

2/7 .464 3/7

3/7 .684 5/7

4/7 .806 6/7

5/7 .904 6/7

6/7 .952 7/7

7/7 1 7/7

The equalized histogram is sk nk 0 0 1/7 400 2/7 700 3/7 800 4/7 0 5/7 900 6/7 900 7/7 396

(b) In histogram specication we want to transform the histogram of an input image into a given distribution. This is done in two phases: rst, equalize the histogram and second, apply transformation that changes the equalized histogram into the given target distribution. In our example, the rst phase was done in part (a). The second phase is done with inverse transform z = G1 (s) where G(z ) is a mapping that equalizes the target distribution. Now we need to compute this mapping: zk ps s k = G( zk ) 0 0.05 0.05 1/7 0.05 0.10 2/7 0.1 0.2 3/7 0.1 0.3 4/7 0.15 0.45 5/7 0.2 0.65 6/7 0.25 0.9 7/7 0.1 1.0

Next we apply the inverse transform z = G1 (s) by nding the closest sk for each sk computed in part (a). rk sk closest sk zk 0 .098 0.10 1/7 1/7 .269 0.3 3/7 2/7 .464 0.45 4/7 3/7 .684 0.65 5/7 4/7 .806 0.9 6/7 5/7 .904 0.9 6/7 6/7 .952 1.0 7/7 7/7 1 1.0 7/7

The histogram resulting from the transform is zk nk 0 0 1/7 400 2/7 0 3/7 700 4/7 800 5/7 900 6/7 900 7/7 396

5. Let us dene the signal-to-noise power ratio as P (x, y ) = For single image this becomes P (x, y ) = = E (f (x, y ) + (x, y ))2 E ( 2 (x, y )) 2 f (x, y ) + 2f (x, y )E ( (x, y )) + E ( 2 (x, y )) E ( 2 (x, y )) E g 2 (x, y ) E ( 2 (x, y ))

= =

f 2 (x, y ) + E ( 2 (x, y )) E ( 2 (x, y )) f 2 (x, y ) +1 E ( 2 (x, y ))

(1)

since E ( (x, y )) = 0. Now, let us compute the average image g (x, y ) and its signal-to-noise power ratio P (x, y ). g (x, y ) = (x, y ) = P E =
1 E K2

1 K

gi (x, y ) = f (x, y ) +
i=1

1 K

i (x, y )
i=1

E g 2 (x, y )
1 K 2 K i=1 i (x, y ) 2 K i=1 i (x, y ) 2 K i=1 i (x, y ) 1 K K i=1 E 1 E K2

E f (x, y ) +

f 2 (x, y ) + = f 2 (x, y ) + =
1 E K2

2 K f (x, y )

(i (x, y )) +
K i=1 i (x, y )

1 E K2 2

2 K i=1 i (x, y )

1 E K2

K i=1 i (x, y )

2 K i=1 i (x, y ) , 2

since E (i (x, y )) = 0. Now,


K 2

E
i=1

i (x, y )

= E
i=1 j =1 K

i (x, y )j (x, y )

2 i (x, y ) + E K K

= E
i=1 K

i (x, y )j (x, y )
i=1 j =i

K 2 E i (x, y ) +

=
i=1

E (i (x, y )) E (j (x, y ))
i=1 j =i

= KE 2 (x, y ) . The second last equity holds since noise is uncorrelated and the last one (x, y ) becomes since E ( (x, y )) = 0. Finally, the signal-to-noise ratio P (x, y ) = P =
1 f 2 (x, y ) + K E 2 (x, y ) 1 2 K E ( (x, y ))

Kf 2 (x, y ) + E 2 (x, y ) E ( 2 (x, y )) 2 f (x, y ) = K + 1, E ( 2 (x, y )) 5

(2)

(x, y ) KP (x, y ). and when P (x, y ) >> 1, P 6. Border handling (a) operator modication operator is modied for exceptions where some of the necessary neighbors are missing often complex seldom used (b) adding zeroes easy to perform often used 0 0 0 0 0 0 1 4 3 0 0 5 8 8 0 0 4 2 5 0 0 0 0 0 0

(c) reecting usually better than adding zeroes often used 1 1 4 3 3 1 1 4 3 3 5 5 8 8 8 4 4 2 5 5 4 4 2 5 5

(d) image is considered to be cyclic seldom used one should have some reason for assuming the image to be periodic 5 4 2 5 4 3 1 4 3 1 8 5 8 8 5 5 4 2 5 4 3 1 4 3 1

(e) only the pixels that have all the necessary neighbors are processed the only right way processed image is smaller than original 1 4 3 5 8 8 4 2 5

You might also like