You are on page 1of 1

Implementing Edge Detectors:

The functions detect edges and perform convolution implement the Kirsch, Prewitt, and Sobeledge detectors. The detect edges function calls perform convolution to detect the edges. Next, itfixes" the edges of the output image (more on this later) and writes it to the output image file.The function perform convolution does the convolution operation eight times (once for each direction) to detect all the edges. First, it calls setup masks to copy the correct masks. Thep a r a m e t e r d e t e c t t y p e d e t e r m i n e s w h i c h m a s k s t o u s e . T h e c o n v e n t i o n i s t y p e 1 = P r e w i t t , 2=Kirsch, and 3=Sobel. The function perform convolution clears the output image, sets severalmaximu m values, and does the convolution eight times over the entire image array. At eachpoint, the code checks to see if the result of convolution is greater than the maximum allowablevalue or less than zero, and corrects for these cases.After convolution, there is the option of thresholding the output of edge detection. Edgedetectors produce results that vary fro m zero to the maximum gray level value. This variationshows the strength of an edge. An edge that changes fro m 10 to 200 will be stronger than onethat changes from 10 to 50. The output of convolution will indicate this strength. It is oftendesirable to threshold the output so strong edges will appear relatively bright (or dark) and weak edges will not appear at all. This lowers the amount of noise in the edge detector output andyields a better picture of the edges. The detect edges and perform convolution functions pass athreshold parameter.If threshold == 1, perform convolution goes through the output image and sets any pixelabove the high parameter to the maximum and any pixel below the high parameter to zero.The quick edge function performs edge detection using the single 3 x 3 quick mask. Itperforms convolution over the image array using the quick mask. It thresholds the output imageif requested, and fixes the edges of the output image. All these operations are the same as in thedetect edges and perform convolution functions.

You might also like