DIP Homework Assignment #2 Edge Detection, Geometrical Modification and Morphological Processing B93501005 CSIE 陳祺文 PROBLEM 1: EDGE DETECTION PART(A) - Pure Edge Detection PART(B) – Edge Detection with Pre-processing PROBLEM 2: Geometrical Modification PROBLEM 3: MORPHOLOGICAL PROCESSING In this part I choose the 2-stage approach introduced on the class, since in this approach, shrinking, thinning, skeletonizing are forms of conditional erosion and the erosion process is controlled to avoid total erasure and to ensure connectivity. < flow chart > F(j,k) M(j,k) Table 14.3-1 find removable candidates G(j,k) Table 14.3-2/3 Conditional array double confirm Stage 1 : Check Table 14.3-1 to generate a conditional array M(j,k) If there’s a hit -> M(j,k)=1, (j,k) is a candidate for erasure. Otherwise, do nothing. Stage 2: Double confirm For each M(j,k)==1, check Table 14.3-2(-3) , if there is a hit -> M(j,k)=0, do not remove (j,k), to avoid total erasure. After stage 2 , if M(j,k)=1, erase (j,k) in the output G(j,k). (In my implementation, I store patterns in the tables in the form of unsigned char[][9] with 0 = 0 , M = 1, A=B=C=2(match all M and 0 , and (A or B or C)==1 means hit), D=3 (don’t care) instead of pixel stack to avoid listing all the patterns. I also construct an additional index table of table 14.3.1 index [S|T|K] [bond-1][start~(end+1)] using pixel bond to decrease the searching range.) <Shrinking> (a)Original image (b) 1 iteration (c) 3 iterations (d) 5 iterations (e) 10 iterations (f) 50 iterations (g) 100 iterations (h) 200 iterations In order to see the effects after several iterations clearly, I replaced the pixels which should be removed with pixel value = 200. From the above resultant images, we can see that an object without holes become a single pixel near its center of mass, while an object with holes become a connected ring lying midway between each hole and its outer boundary. Moreover, if the original object is a line, the object erodes from the end points, finally becomes a single point. (for example , the V shape line at the bottom right corner.) And even after lots of iterations, the image won’t be total erasure , the rings still keep the shape of the ring. <Thinning> (a)Original image (d) 5 iterations (g) 15 iterations (b) 1 iteration (c) 3 iterations (e) 10 iterations (f) 12 iterations (h) 50 iterations Comparing the resultant images of shrinking and thinning, in the first few iterations (<10) the output image is almost the same. Finally, an object with holes erodes to a connected ring, and different from the effect of shrinking, an object without holes become a minimally connected stroke located equidistant from its nearest outer boundaries rather than a single pixel. The other difference is that the thinning effects stop after 15 iterations, after 50 or more iterations the resultant image is the same, while we can see the shrinking effects after 200 iterations, the lines erodes slowly to a single pixel, and that cause thinning keeps more structural feature of the original feature than shrinking. <Skeletonizing> (a)Original image (d) 5 iterations (g) 20 iterations (b) 1 iteration (c) 3 iterations (e) 10 iterations (f) 15 iterations (h) 50 iterations (i) 200 iterations