1、Digital Image Processing Second Edition Problem SolutionswStudent Set Rafael C. Gonzalez Richard E. Woods Prentice Hall Upper Saddle River, NJ 07458 or ii Revision history 10 9 8 7 6 5 4 3 2 1 Copyright c 19922002 by Rafael C. Gonzalez and Richard E. Woods1 Preface This abbreviated manual contains
2、detailed solutions to all problems marked with a star in Digital Image Processing, 2nd Edition. These solutions can also be downloaded from the book web site ().2 Solutions (Students) Problem 2.1 The diameter, x, of the retinal image corresponding to the dot is obtained from similar triangles, as sh
3、own in Fig. P2.1. That is, (d=2) 0:2 = (x=2) 0:014 which gives x = 0:07d. From the discussion in Section 2.1.1, and taking some liberties of interpretation, we can think of the fovea as a square sensor array having on the order of 337,000 elements, which translates into an array of size 580 580 elem
4、ents. Assuming equal spacing between elements, this gives 580 elements and 579 spaces on a line 1.5 mm long. The size of each element and each space is then s = (1:5mm)=1; 159 = 1:310 6 m. If the size (on the fovea) of the imaged dot is less than the size of a single resolution element, we assume th
5、at the dot will be invisible to the eye. In other words, the eye will not detect a dot if its diameter, d, is such that 0:07(d) 1:3 10 6 m, or d 18:6 10 6 m. Figure P2.14 Chapter 2 Solutions (Students) Problem 2.3 = c=v = 2:998 10 8 (m/s)=60(1/s) = 4:99 10 6 m = 5000 Km. Problem 2.6 One possible sol
6、ution is to equip a monochrome camera with a mechanical device that sequentially places a red, a green, and a blue pass lter in front of the lens. The strongest camera response determines the color. If all three responses are approximately equal, the object is white. A faster system would utilize th
7、ree different cameras, each equipped with an individual lter. The analysis would be then based on polling the response of each camera. This system would be a little more expensive, but it would be faster and more reliable. Note that both solutions assume that the eld of view of the camera(s) is such
8、 that it is completely lled by a uniform color i.e., the camera(s) is(are) focused on a part of the vehicle where only its color is seen. Otherwise further analysis would be required to isolate the region of uniform color, which is all that is of interest in solving this problem. Problem 2.9 (a) The
9、 total amount of data (including the start and stop bit) in an 8bit, 1024 1024 image, is (1024) 2 8 + 2 bits. The total time required to transmit this image over a At 56K baud link is (1024) 2 8 + 2=56000 = 187:25 sec or about 3.1 min. (b) At 750K this time goes down to about 14 sec. Problem 2.11 Le
10、t p and q be as shown in Fig. P2.11. Then, (a) S 1 and S 2 are not 4connected because q is not in the set N 4 (p)u (b) S 1 and S 2 are 8connected because q is in the set N 8 (p)u (c) S 1 and S 2 are mconnected because (i) q is in N D (p), and (ii) the set N 4 (p) N 4 (q) is empty.Problem 2.12 5 Figu
11、re P2.11 Problem 2.12 The solution to this problem consists of dening all possible neighborhood shapes to go from a diagonal segment to a corresponding 4connected segment, as shown in Fig. P2.12. The algorithm then simply looks for the appropriate match every time a diagonal segment is encountered i
12、n the boundary. Figure P2.12 Problem 2.15 (a) When V = f0; 1g, 4path does not exist between p and q because it is impossible to6 Chapter 2 Solutions (Students) get from p to q by traveling along points that are both 4adjacent and also have values from V . Figure P2.15(a) shows this conditionu it is
13、not possible to get to q. The shortest 8path is shown in Fig. P2.15(b)u its length is 4. The length of shortest m path (shown dashed) is 5. Both of these shortest paths are unique in this case. (b) One possibility for the shortest 4path when V = f1;2g is shown in Fig. P2.15(c)u its length is 6. It i
14、s easily veried that another 4path of the same length exists between p and q. One possibility for the shortest 8path (it is not unique) is shown in Fig. P2.15(d)u its length is 4. The length of a shortest mpath (shoen dashed) is 6. This path is not unique. Figure P2.15 Problem 2.16 (a) A shortest 4p
15、ath between a point p with coordinates (x;y) and a point q with coor dinates (s; t) is shown in Fig. P2.16, where the assumption is that all points along the path are from V . The length of the segments of the path are jx sj and jy tj, respec tively. The total path length is jx sj + jy tj, which we
16、recognize as the denition of the D 4 distance, as given in Eq. (2.516). (Recall that this distance is independent of any paths that may exist between the points.) The D 4 distance obviously is equal to the length of the shortest 4path when the length of the path is jx sj + jy tj. This oc curs whenev
17、er we can get from p to q by following a path whose elements (1) are from V; and (2) are arranged in such a way that we can traverse the path from p to q by mak ing turns in at most two directions (e.g., right and up). (b) The path may of may not be unique, depending on V and the values of the point
18、s along the way.Problem 2.18 7 Figure P2.16 Problem 2.18 With reference to Eq. (2.61), let H denote the neighborhood sum operator, let S 1 and S 2 denote two different small subimage areas of the same size, and let S 1 +S 2 denote the corresponding pixelbypixel sum of the elements in S 1 and S 2 , a
19、s explained in Section 2.5.4. Note that the size of the neighborhood (i.e., number of pixels) is not changed by this pixelbypixel sum. The operator H computes the sum of pixel values is a given neighborhood. Then, H(aS 1 + bS 2 ) means: (1) multiplying the pixels in each of the subimage areas by the
20、 constants shown, (2) adding the pixelbypixel values fromS 1 and S 2 (which produces a single subimage area), and (3) computing the sum of the values of all the pixels in that single subimage area. Let ap 1 and bp 2 denote two arbitrary (but corresponding) pixels from aS 1 + bS 2 . Then we can write
21、 H(aS 1 + bS 2 ) = X p 1 2S 1 and p 2 2S 2 ap 1 + bp 2 = X p1 2S1 ap 1 + X p22S2 bp 2 = a X p1 2S1 p 1 + b X p2 2S2 p 2 = aH(S 1 ) + bH(S 2 ) which, according to Eq. (2.61), indicates that H is a linear operator.3 Solutions (Students) Problem 3.2 (a) s = T(r) = 1 1 + (m=r) E : Problem 3.4 (a) The nu
22、mber of pixels having different gray level values would decrease, thus causing the number of components in the histogram to decrease. Since the number of pixels would not change, this would cause the height some of the remaining histogram peaks to increase in general. Typically, less variability in
23、gray level values will reduce contrast. Problem 3.5 All that histogram equalization does is remap histogram components on the intensity scale. To obtain a uniform (at) histogram would require in general that pixel intensities be actually redistributed so that there are L groups of n=L pixels with th
24、e same intensity, where L is the number of allowed discrete intensity levels and n is the total number of pixels in the input image. The histogram equalization method has no provisions for this type of (articial) redistribution process. Problem 3.8 We are interested in just one example in order to s
25、atisfy the statement of the problem. Consider the probability density function shown in Fig. P3.8(a). A plot of the trans formation T(r) in Eq. (3.34) using this particular density function is shown in Fig. P3.8(b). Because p r (r) is a probability density function we know from the discussion10 Chap
26、ter 3 Solutions (Students) in Section 3.3.1 that the transformation T(r) satises conditions (a) and (b) stated in that section. However, we see from Fig. P3.8(b) that the inverse transformation from s back to r is not single valued, as there are an innite number of possible mappings from s = 1=2 bac
27、k to r. It is important to note that the reason the inverse transformation function turned out not to be single valued is the gap in p r (r) in the interval 1=4; 3=4. Figure P3.8. Problem 3.9 (c) If none of the gray levels r k ; k = 1;2;:;L 1; are 0, then T(r k ) will be strictly monotonic. This imp
28、lies that the inverse transformation will be of nite slope and this will be singlevalued. Problem 3.11 The value of the histogram component corresponding to the kth intensity level in a neigh borhood is p r (r k ) = n k nProblem 3.14 11 for k = 1;2;:;K 1;where n k is the number of pixels having gray
29、 level value r k , n is the total number of pixels in the neighborhood, and K is the total number of possible gray levels. Suppose that the neighborhood is moved one pixel to the right. This deletes the leftmost column and introduces a new column on the right. The updated histogram then becomes p 0
30、r (r k ) = 1 n n k n L k + n R k for k = 0;1;:;K 1, where n L k is the number of occurrences of level r k on the left column and n R k is the similar quantity on the right column. The preceding equation can be written also as p 0 r (r k ) = p r (r k ) + 1 n n R k n L k for k = 0; 1;:;K 1: The same c
31、oncept applies to other modes of neighborhood motion: p 0 r (r k ) = p r (r k ) + 1 n b k a k for k = 0;1;:;K 1, where a k is the number of pixels with value r k in the neighbor hood area deleted by the move, and b k is the corresponding number introduced by the move. 2 g = 2 f + 1 K 2 2 1 + 2 2 + +
32、 2 K The rst term on the right side is 0 because the elements of f are constants. The various 2 i are simply samples of the noise, which is has variance 2 . Thus, 2 i = 2 and we have 2 g = K K 2 2 = 1 K 2 which proves the validity of Eq. (3.45). Problem 3.14 Let g(x;y) denote the golden image, and l
33、et f(x;y) denote any input image acquired during routine operation of the system. Change detection via subtraction is based on computing the simple difference d(x;y) = g(x;y) f(x;y). The resulting image d(x;y) can be used in two fundamental ways for change detection. One way is use a pixelbypixel an
34、alysis. In this case we say that f(x;y) is close enough to the golden image if all the pixels in d(x;y) fall within a specied threshold band T min ;T max where T min is negative and T max is positive. Usually, the same value of threshold is12 Chapter 3 Solutions (Students) used for both negative and
35、 positive differences, in which case we have a band T;T in which all pixels of d(x;y) must fall in order for f(x;y) to be declared acceptable. The second major approach is simply to sum all the pixels in jd(x;y)j and compare the sum against a threshold S. Note that the absolute value needs to be use
36、d to avoid errors cancelling out. This is a much cruder test, so we will concentrate on the rst approach. There are three fundamental factors that need tight control for differencebased inspec tion to work: (1) proper registration, (2) controlled illumination, and (3) noise levels that are low enoug
37、h so that difference values are not affected appreciably by variations due to noise. The rst condition basically addresses the requirement that comparisons be made between corresponding pixels. Two images can be identical, but if they are displaced with respect to each other, comparing the differenc
38、es between them makes no sense. Often, special markings are manufactured into the product for mechanical or imagebased alignment Controlled illumination (note that |illumination is not limited to visible light) obviously is important because changes in illumination can affect dramatically the values
39、 in a difference image. One approach often used in conjunction with illumination control is intensity scaling based on actual conditions. For example, the products could have one or more small patches of a tightly controlled color, and the intensity (and perhaps even color) of each pixels in the ent
40、ire image would be modied based on the actual versus expected intensity and/or color of the patches in the image being processed. Finally, the noise content of a difference image needs to be low enough so that it does not materially affect comparisons between the golden and input images. Good signal
41、 strength goes a long way toward reducing the effects of noise. Another (sometimes complementary) approach is to implement image processing techniques (e.g., image averaging) to reduce noise. Obviously there are a number if variations of the basic theme just described. For exam ple, additional intel
42、ligence in the form of tests that are more sophisticated than pixelby pixel threshold comparisons can be implemented. A technique often used in this regard is to subdivide the golden image into different regions and perform different (usually more than one) tests in each of the regions, based on exp
43、ected region content. Problem 3.17 (a) Consider a 3 3 mask rst. Since all the coefcients are 1 (we are ignoring the 1/9Problem 3.19 13 scale factor), the net effect of the lowpass lter operation is to add all the gray levels of pixels under the mask. Initially, it takes 8 additions to produce the re
44、sponse of the mask. However, when the mask moves one pixel location to the right, it picks up only one new column. The new response can be computed as R new = R old C 1 + C 3 where C 1 is the sum of pixels under the rst column of the mask before it was moved, and C 3 is the similar sum in the column
45、 it picked up after it moved. This is the basic boxlter or movingaverage equation. For a 3 3 mask it takes 2 additions to get C 3 (C 1 was already computed). To this we add one subtraction and one addition to get R new . Thus, a total of 4 arithmetic operations are needed to update the response afte
46、r one move. This is a recursive procedure for moving from left to right along one row of the image. When we get to the end of a row, we move down one pixel (the nature of the computation is the same) and continue the scan in the opposite direction. For a mask of size n n, (n 1) additions are needed
47、to obtain C 3 , plus the single subtraction and addition needed to obtain R new , which gives a total of (n + 1) arith metic operations after each move. A bruteforce implementation would require n 2 1 additions after each move. Problem 3.19 (a) There are n 2 points in an n n median lter mask. Since
48、n is odd, the median value, , is such that there are (n 2 1)=2 points with values less than or equal to and the same number with values greater than or equal to . However, since the area A (number of points) in the cluster is less than one half n 2 , and A and n are integers, it follows that A is always less than or equal to (n 2 1)=2. Thus, even in the extreme case when all cluster points are encompassed by the lter mask, there are not enough points in the cluster for any of them to be equal to the value of the median (remember, we are assuming that all cluster points are li