Edge Detection Algorithms (original) (raw)

Last Updated : 11 Jun, 2026

Edge detection is a technique in image processing and computer vision used to identify significant changes in image intensity that often correspond to object boundaries. By detecting these boundaries, edge detection helps extract important structural information from an image.

**Key Characteristics

Types of Edges

**1. Step Edges: A step edge occurs when the intensity changes abruptly from one region to another, creating a distinct transition between neighboring areas in an image.

**2. Line Edges: A line edge is formed when the intensity changes over a narrow region and then returns to a similar level, producing a thin bright or dark line.

**3. Junction Edges: A junction edge is created where multiple edges meet or intersect, forming points that connect different regions or boundaries within an image.

Edge Detection Techniques

Edge detection techniques identify object boundaries by detecting significant changes in image intensity. Based on their approach, edge detection methods can be classified into the following categories:

Gradient-Based Methods

1. Sobel Operator

The Sobel operator is a discrete differentiation operator that computes an approximation of the gradient of the image intensity function. It uses convolutional masks to highlight regions with high spatial frequency, which correspond to edges.

The Sobel operator uses two 3x3 convolution masks, one for detecting changes in the horizontal direction (Gx) and one for the vertical direction (Gy).

\begin{bmatrix} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1\end{bmatrix} \quad\begin{bmatrix} -1 & -2 & -1 \\ 0 & 0 & 0 \\ 1 & 2 & 1\end{bmatrix}

The gradient magnitude is then computed as:

G = \sqrt{G_{x}^{2} + G_{y}^{2}}

**Advantages

**Disadvantages

2. Prewitt Operator

The Prewitt operator is similar to the Sobel operator but uses a different convolution mask. It also approximates the gradient of the image intensity function, focusing on edge detection.

The Prewitt operator uses the following 3x3 convolution masks for horizontal (Gx) and vertical (Gy) edge detection:

\begin{bmatrix} -1 & 0 & 1 \\ -1 & 0 & 1 \\ -1 & 0 & 1\end{bmatrix} \quad\begin{bmatrix} -1 & -1 & -1 \\ 0 & 0 & 0 \\ 1 & 1 & 1\end{bmatrix}

The gradient magnitude is computed similarly:

G = \sqrt{G_{x}^{2} + G_{y}^{2}}

**Advantages

**Disadvantages

3. Roberts Cross Operator

The Roberts Cross operator is an early edge detection method that computes the gradient at a point in the image using the differences between diagonally adjacent pixels. It emphasizes edge detection along the diagonals.

The Roberts Cross operator uses two 2x2 convolution masks for diagonal edge detection:

\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \quad\begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}

The gradient magnitude is then computed as:

G = \sqrt{G_{x}^{2} + G_{y}^{2}}

**Advantages

**Disadvantages

Laplacian of Gaussian (LoG)

The Laplacian of Gaussian combines Gaussian smoothing with the Laplacian operator to detect edges while reducing the impact of image noise. It identifies edges by locating regions of rapid intensity change.

**Mathematical Formulation

  1. **Gaussian Smoothing: The image is first smoothed using a Gaussian filter to reduce noise. The Gaussian filter is defined as: G(x,y) = \frac{1}{2 \pi \sigma^2 } e^{\frac{x^2 + y^2 }{2 \sigma^2}}, \sigma is the standard deviation of the Gaussian.
  2. **Laplacian Operator: The Laplacian operator is then applied to the smoothed image. The Laplacian is defined as: \nabla^ 2 f(x,y) = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2}
  3. **LoG: The combined LoG operator is the result of convolving the Gaussian-smoothed image with the Laplacian: LoG(x,y) = \nabla^2 (G(x,y) * I(x,y))

**Advantages

**Disadvantages

Canny Edge Detector

The Canny Edge Detector is a multi-stage algorithm designed to achieve accurate edge detection with good localization and reduced sensitivity to noise. It is one of the most widely used edge detection techniques.

**Steps Involved:

  1. **Smoothing: The first step involves reducing noise in the image using a Gaussian filter: G(x,y) = \frac{1}{2 \pi \sigma^2} e ^ {\frac{x^2 + y^2}{2 \sigma^2}}. The image is convolved with this Gaussian kernel to produce a smoothed image.
  2. **Finding Gradients: The gradients of the smoothed image are computed using finite difference approximations, typically with the Sobel operator. The gradient magnitude is then computed as: G = \sqrt{G_{x}^{2} + G_{y}^{2}} , \quad \theta = \tan^{-1}\frac{G_y}{G_x}.
  3. **Non-Maximum Suppression: This step involves thinning the edges by suppressing non-maximum gradient values. Only the local maxima in the direction of the gradient are preserved, resulting in a set of thin edges.
  4. **Double Thresholding: Two thresholds, T_{\text{low }} \text{and } T_{\text{high}} ​, are applied to classify the gradient magnitudes into strong, weak, and non-relevant pixels:
    • Strong edges: G \geq T_{\text{high}}
    • Weak edges: T_{\text{low}} \leq G < T_{\text{high}}
    • Non-relevant pixels: G < T_{\text{low}}
  5. **Edge Tracking by Hysteresis: Weak edges connected to strong edges are preserved, while others are discarded. This step ensures continuity and accuracy in edge detection by linking weak edge pixels that form a continuous line with strong edges.

**Advantages

**Disadvantages

Applications