9 c] Explain canny edge detection algorithm.
Canny Edge Detection Algorithm
The Canny edge detection algorithm is a popular technique used in image processing to detect edges in an image. It is designed to optimize the balance between detecting true edges, accurately locating them, and minimizing the detection of false edges. The steps involved in the Canny edge detection process are as follows:
Key Objectives of the Canny Edge Detection Algorithm:
- Good Edge Detection: The algorithm should detect only the actual edge points in an image, effectively discarding any false edges that do not correspond to real edges.
- Good Edge Localization: The detected edge points should be as close as possible to the actual edges in the image, ensuring precise edge localization.
- Single Response to Each Edge: The algorithm should produce only one edge response per edge, avoiding any false, double, or spurious edges.
Steps in the Canny Edge Detection Algorithm:
- Gaussian Smoothing:
- The first step involves convolving the image with a Gaussian filter to smooth it, reducing noise and minor details that might be mistaken for edges. The gradient of the smoothed image is then computed, which gives the edge magnitude ( M(x, y) ) and edge orientation ( \theta(x, y) ). These are stored separately in two arrays.
2. Non-Maxima Suppression:
- After obtaining the edge magnitude and orientation, the edges need to be thinned to ensure they are well-defined. This is done through non-maxima suppression, which examines the gradient direction of each edge point. Instead of analyzing every possible direction (0-360°), the gradient direction is reduced to four sectors by dividing the range into eight equal parts, with two parts forming one sector.
- For a given point ( M(x, y) ), the edge magnitudes of two neighboring pixels along the same gradient direction are compared. If the magnitude at ( M(x, y) ) is less than that of its neighbors, the value at ( M(x, y) ) is suppressed (set to zero). Otherwise, the value is retained.
3. Hysteresis Thresholding:
- The final step involves applying hysteresis thresholding to identify strong and weak edges. This technique uses two thresholds:
- High Threshold (( T_H )): If the gradient magnitude at a pixel is greater than ( T_H ), it is considered a definite edge point.
- Low Threshold (( T_L )): If the gradient magnitude is below ( T_L ), the pixel is classified as noise and discarded.
- If the gradient magnitude falls between ( T_L ) and ( T_H ), the pixel is considered a weak edge point, and its classification depends on its context.
- Two images are generated using the high and low thresholds. The image with the high threshold contains strong edges but may have gaps. The low threshold image, which may include more noise, is used to bridge these gaps. The neighboring pixels of weak edges in the low-threshold image are examined, and if they connect to strong edges, they are kept, ensuring the edges in the final image are continuous and accurately represent the contours of the original image.
This process ensures that the Canny edge detector effectively detects true edges, accurately locates them, and minimizes the detection of false or duplicate edges, resulting in a clean and precise edge map of the image.