Draft:Edge Detection Algorithms

Source: Wikipedia, the free encyclopedia.


Introduction To Canny Edge Detection Algorithm

The Canny Edge Detection Algorithm introduced by John F. Canny in 1986 , Canny Edge Detection Algorithm is a multi statge algorithm .Edge detection is a important for image Segmentation , Since many image processing algorithms are first required to identify the object and then process them.In the algorithm their are Multi statge is given below .

1 . NOICE REDUCTION

2 . GRADIENT CALCULATION

3 . NON-MAXIMUM SUPPRESSION

4 . DOUBLE THRESHOLDING AND EDGE

5 . EDGE TRACKING BY HYSTERESIS


Step's To Perform Canny Edge Detection

1 . START

2 . LOAD A COLOR IMAGE

3 . CONVERT TO A BINARY IMAGE

4 . APPLY CANNY EDGE DETECTION ALGORITHM

5 . END

REFERENCE OF FLOWCHART OF CANNY EDGE DETECTION


1 . NOICE REDUCTION This is initial step of Canny Edge Detection Algorithm . The primary objective of Canny Edge detection algorithm is Noice Reduction . The Noice Reduction work within the Canny Edge Detection Algorithm is given below

Gaussian Blur :The first step in noise reduction is to convolve the input image with a Gaussian filter kernel.

Impact on Noise :Gaussian blur effectively reduces high-frequency components in the image, which are typically associated with noise.

Computational Efficiency : In practical implementations of the Canny algorithm, Gaussian blur is often performed using a separable filter to improve computational efficiency.

Integration with Edge Detection:After noise reduction, the smoothed image is then passed through subsequent stages of the Canny algorithm

Parameter Tuning :The effectiveness of noise reduction in the Canny algorithm depends on the choice of parameters, such as the standard deviation of the Gaussian kernel (which determines the amount of smoothing) and the threshold values used for edge detection.

2 . GRADIENT CALCULATION Gradient calculation plays a crucial role in the Canny edge detection algorithm by identifying areas of significant intensity change, which serve as potential edge candidates for further processing in subsequent stages of the algorithm. The Gradient Calculation work within the Canny Edge Detection Algorithm is given below

Gradient Approximation: The first step in gradient calculation involves approximating the gradients of the image using edge detection filters, such as the Sobel or Prewitt operators.

Sobel Operator: One commonly used edge detection filter is the Sobel operator, which consists of two separate 3x3 convolution kernels: one for horizontal changes and the other for vertical changes.

Gradient Magnitude: Once the horizontal and vertical gradients are computed, the gradient magnitude at each pixel can be obtained using the formula

Gradient Direction: The gradient direction at each pixel is calculated using the formula

Edge Strength and Orientation: The resulting gradient magnitude and direction provide valuable information about the strength and orientation of edges in the image.

Normalization and Scaling: It's common practice to normalize the gradient magnitude to ensure that it falls within a specific range (typically 0 to 255) Gradient Maps: The computed gradient magnitude and direction can be visualized as gradient magnitude maps and gradient orientation maps.

3 . NON-MAXIMUM SUPPRESSION non-maximum suppression is a crucial step in the Canny edge detection algorithm, as it refines the edge map obtained from gradient calculation by retaining only the most relevant edge responses and discarding non-maximal responses. The Non-Maximum Suppression work within the Canny Edge Detection Algorithm is given below

Gradient Magnitude and Direction: After computing the gradient magnitude and direction using techniques like Sobel or Prewitt operators, each pixel in the image has associated gradient strength and direction.

Local Maximum Detection: For each pixel in the image, non-maximum suppression checks if the gradient magnitude at that pixel is a local maximum along the direction of the gradient.

Suppression of Non-Maximum Pixels: If a pixel's gradient magnitude is not greater than its neighbors along the gradient direction, it is suppressed.

Resulting Edge Thinning: By applying non-maximum suppression, the edges in the image are thinned to a one-pixel width, enhancing the precision of edge detection.

Edge Response Preservation: Non-maximum suppression helps preserve only the sharpest and most prominent edges.

Directional Filtering: The suppression process is typically performed along the gradient direction to ensure that only edges with the steepest intensity changes are retained.

4 . DOUBLE THRESHOLDING AND EDGE Double thresholding and edge tracking by hysteresis play a crucial role in the Canny edge detection algorithm by effectively distinguishing between strong, weak, and non-edge pixels and connecting weak edges to form continuous edge contours. The Double Thresholding and edge work within the Canny Edge Detection Algorithm is given below

Thresholding: In this step, the gradient magnitudes obtained from the previous stages are compared against two user-defined thresholds: a high threshold (T_high) and a low threshold (T_low).

Strong Edge Pixels: Any pixel with a gradient magnitude greater than or equal to the high threshold (T_high) is classified as a strong edge pixel.

Weak Edge Pixels: Pixels with gradient magnitudes between the low threshold (T_low) and the high threshold (T_high) are classified as weak edge pixels.

Non-Edge Pixels: Pixels with gradient magnitudes below the low threshold (T_low) are classified as non-edge pixels and are discarded from further consideration.

Edge Tracking by Hysteresis: After thresholding, weak edge pixels are subjected to a process called edge tracking by hysteresis.

Connected Component Analysis: Edge tracking involves examining neighboring pixels of weak edge pixels to determine if they are connected to strong edge pixels.

Threshold Selection: The choice of high and low thresholds is critical and depends on factors such as image noise level and edge detection requirements.

Adjustment and Optimization: The selection of threshold values often involves empirical tuning and optimization based on the specific characteristics of the input images and the desired edge detection performance.

5 . EDGE TRACKING BY HYSTERESIS Edge tracking by hysteresis is a crucial component of the Canny edge detection algorithm, enabling the formation of continuous edge contours by connecting weak edge pixels to strong edge pixels based on a hysteresis-based thresholding logic. The Edge Tracking By Hysteresis work within the Canny Edge Detection Algorithm is given below

Weak Edge Pixel Selection: In the previous step of double thresholding, weak edge pixels were identified based on their gradient magnitudes falling between the low and high thresholds.

Initialization: Edge tracking begins by selecting a starting point, typically a strong edge pixel with a gradient magnitude exceeding the high threshold.Edge Following: From the initial seed pixel, edge tracking proceeds by iteratively examining neighboring pixels to determine if they should be included as part of the edge.

Thresholding Logic: The inclusion of weak edge pixels is governed by a concept of hysteresis, which involves two thresholds: a high threshold (T_high) and a low threshold (T_low).

Continuity Preservation: By incorporating hysteresis-based thresholding, edge tracking ensures the continuity of edges by allowing weak edge pixels to be included if they are part of a continuous edge structure

Recursive Exploration: Edge tracking continues recursively, exploring neighboring pixels of included weak edge pixels to identify additional edge pixels.

Termination: Edge tracking terminates when no more weak edge pixels satisfying the threshold conditions are found in the neighborhood of the currently tracked edge.

Output: The result of edge tracking by hysteresis is a set of connected edge segments, comprising both strong and weak edge pixels


The OpenCv code of Canny Edge detection Algorithm in Python


import cv2

import numpy as np

image = cv2.imread(test_img)

image=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)


gradient_sobelx = cv2.Sebel(image , -1,-1,0)

gradient_sobely = cv2.Sebel(image , -1,0,1)

gradient_sobelxy = cv2.addWeighted(gradient_sobelx , 0.5 , gradients_sobely , 0.5,0)


gradients_laplacian=cv2.Laplacian(image , -10)


canny_output = cv2.Canny(image , 80,150)


cv2.imshow('Sobel x' gradients_sobelx)

cv2.imshow('Sobel y' gradients_sobely)

cv2.imshow('Sobel x+y' gradients_sobelxy)

cv2.imshow('laplacian' gradients_laplacian)

cv2.imshow('canny' canny_output)

cv2.waitKey()


REFERENCES

[1]. "Edge detection". Wikipedia. 24 February 2024. Retrieved 28 April 2024.

[2]. M, Vikram (6 August 2022). "Comprehensive Guide to Edge Detection Algorithms". Analytics Vidhya. Vikram M. Retrieved 9 August 2022.

[3]. "Image Edge Detection Operators in Digital Image Processing". GeeksforGeeks. 10 May 2020.

[4]. Sahir, Sofiane (27 January 2019). "Canny Edge Detection Step by Step in Python — Computer Vision". Medium. Retrieved 25 January 2019.

[5]. "OpenCV: Canny Edge Detection". docs.opencv.org.

[6]. Team, Towards AI. "What is a Canny Edge Detection Algorithm? – Towards AI". Retrieved 17 September 2020.

[7]. Yuan, Liying (2015). Adaptive Image Edge Detection Algorithm Based on Canny Operator. IEEE. pp. 28–31.

ISBN 978-1-4673-7572-6. Retrieved 4 February 2016. {{cite book}}: |website= ignored (help
)