You are on page 1of 15

Edge Detection Algorithms

Dr Arunachalam V
Associate Professor, SENSE
Introduction
• Edge detection includes a variety of mathematical methods that aim at identifying edges and
curves in a digital image at which the image brightness changes sharply or, more formally,
has discontinuities.
• The same problem of finding discontinuities in one-dimensional signals is known as step
detection and the problem of finding signal discontinuities over time is known as change
detection.
• Edge detection is a fundamental tool in image processing, machine vision and computer vision,
particularly in the areas of feature detection and feature extraction.
Purpose & Significant of Edge Detection
• The result of applying an edge detector to an image may lead to a set of connected curves that
indicate as follows:
• The boundaries of objects,
• The boundaries of surface markings as well as curves that correspond to discontinuities in surface
orientation.
• Applying an edge detection algorithm to an image may significantly reduce the amount of data to
be processed and filter out information that may be regarded as less relevant while preserving the
important structural properties of an image.
• If the edge detection step succeeds, the subsequent task of interpreting the information contents in
the original image may be substantially simplified.
• However, it is not always possible to obtain such ideal edges from real time images of moderate
complexity.
Viewpoint dependency on Edges’ Properties
• The edges extracted from a 2-D image of a 3-D scene can be classified as either viewpoint-
dependent or viewpoint-independent.
• A viewpoint-independent edge typically reflects inherent properties of the three-dimensional
objects, such as surface markings and surface shape.
• A viewpoint-dependent edge may change as the viewpoint changes and typically reflects the
scene’s geometry, such as objects overlapping with one another object.
Types of Edges
• Edges are significant local changes of intensity in a digital image.
• An edge can be defined as a set of connected pixels that forms a boundary between two disjoint
regions.
• There are three types of edges:
• Horizontal edges
• Vertical edges
• Diagonal edges
Applications of Edge detection
• Edge Detection is a method of segmenting an image into regions of discontinuity.
• It is a widely used technique in digital image processing like
• Pattern recognition
• Image morphology
• Feature extraction
Edge Detection Operators
• Edge Detection Operators are of two types:
• Gradient-based operator which computes first-order derivations in a digital image.
• Examples: Sobel operator, Prewitt operator, Robert operator
• Gaussian-based operator which computes second-order derivations in a digital image.
• Examples: Canny edge detector, Laplacian of Gaussian
Sobel Edge Detector
• It is a discrete differentiation gradient-based operator.
• It computes the gradient approximation of the image intensity function for image edge detection.
• It uses two 3 × 3 kernels/convolution masks, which are convolved with the input image to
calculate the vertical (𝑆𝑥 ) and horizontal (𝑆𝑦 ) derivative approximations.
−1 0 +1 +1 +2 +1
• 𝑠𝑥 = −2 0 +2 𝑠𝑦 = 0 0 0
−1 0 +1 −1 −2 −1
2 2
• Magnitude of the gradient is , 𝑚𝑖,𝑗 = 𝑠𝑥(𝑖,𝑗) + 𝑠𝑦(𝑖,𝑗)
Steps Involved in Sobel Operation
• The Sobel algorithm can be summarized in four steps:
1. Converting the image into grayscale
2. Convolving the gray image, calculate using 𝑆𝑥
3. Convolving the gray image , calculate using 𝑆𝑦
4. Calculating the gradient magnitude, M
A working example of Sobel filter
• Suppose we have the same 5*5 image.
i.j 1 2 3 4 5
• Use zero padding on the input image.
1 0 0 10 10 10
• To maintain size at the output stage. 2 0 0 10 10 10
0 0 0 −1 0 +1 3 0 0 10 10 10
• 𝑠𝑥(1,1)
= 𝐼1,1 ∗ 𝑠𝑥 = 0 𝟎 0 ∗ −2 0 +2 = 0
0 0 0 −1 0 +1 4 0 0 10 10 10
0 0 0 −1 0 +1 5 0 0 10 10 10
• 𝑠𝑥(1,2) = 𝐼1,2 ∗ 𝑠𝑥 = 𝐼0,1 ∗ 𝑠𝑥 = 0 𝟎 10 ∗ −2 0 +2 = 30
0 0 10 −1 0 +1 i.j 1 2 3 4 5
10 10 10 +1 +2 +1 1 0 30
• 𝑠𝑦(3,4) = 𝐼3,4 ∗ 𝑆𝑦 = 10 𝟏𝟎 10 ∗ 0 0 0 =0 2
10 10 10 −1 −2 −1
3 0
0 10 10 +1 +2 +1
• 𝑠𝑦(4,3) = 𝐼4,3 ∗ 𝑆𝑦 = 0 𝟏𝟎 10 ∗ 0 0 0 =0 4 0
0 10 10 −1 −2 −1 5
A working example of Sobel filter
• The gradient in x direction, (𝑆𝑥 ) using filter 𝑠𝑥
i.j 1 2 3 4 5
1 0 30 30 0 -30
2 0 40 40 0 -40
3 0 40 40 0 -40
4 0 40 40 0 -40
5 0 30 30 0 -30

• The gradient in y direction, (𝑆𝑦 ) using filter 𝑠𝑦

i.j 1 2 3 4 5
1 0 -10 -30 -40 -30
2 0 0 0 0 0
3 0 0 0 0 0
4 0 0 0 0 0
5 0 10 30 40 30
A working example of Sobel filter
• 𝑆𝑥 i.j 1 2 3 4 5 𝑆𝑦 i.j 1 2 3 4 5
1 0 -10 -30 -40 -30
1 0 30 30 0 -30
2 0 0 0 0 0
2 0 40 40 0 -40
3 0 0 0 0 0
3 0 40 40 0 -40
4 0 0 0 0 0
4 0 40 40 0 -40
5 0 10 30 40 30
5 0 30 30 0 -30

• Calculate the gradient Magnitude = 𝑆𝑥 2 + 𝑆𝑦 2

i.j 1 2 3 4 5 The pixels, (1,2), (2,2), (3,2), (4,2) and (5,2) are
1 0 31.62 42.43 40 42.43 larger values than (1,1), (2,1), (3,1), (4,1) and
2 0 40 40 0 40 (5,1) therefore (1,2), (2,2), (3,2), (4,2) and (5,2)
3 0 40 40 0 40 are the edge pixels.
4 0 40 40 0 40
5 0 31.62 42.43 40 42.43
𝑆𝑥 1 2 3 4 5
I 1 2 3 4 5
1 -4 -30 0 -30 4
1 0 2 15 0 0
2 -12 -31 -115 -328 127
2 0 0 0 4 60
3 -34 -202 -463 -591 497
3 0 10 16 119 238
4 -136 -611 -748 -393 884
4 0 14 170 255 255
5 -210 -680 -555 -85 765
5 0 98 255 255 255
𝑆𝑦 1 2 3 4 5

𝑀 1 2 3 4 5 1 0 0 -4 -68 -124

1 4 30 4 74 124 2 -8 -17 -129 -478 -597


-14
2 14 35 172 579 610 3 -198 -605 -867 -641
3 36 282 761 1049 811
4 -88 -415 -702 -527 -168
4 162 738 1025 657 899
5 14 198 609 935 765
5 210 708 824 938 1081
Sobel Edge Detection
Advantages:
1. Simple and time-efficient computation
2. Very easy at searching for smooth edges
Limitations:
1. Diagonal direction points are not preserved always
2. Highly sensitive to noise
3. Not very accurate in edge detection
4. Detect with thick and rough edges does not give appropriate results
References
• Canny Edge Detector (justin-liang.com)
• Sobel Edge Filter. We can think of an image, which is… | by Shailesh
Kumpawat | Analytics Vidhya | Medium
• Week 4: Image Filtering and Edge Detection (sbme-tutorials.github.io)
• Canny edge detector – Wikipedia
• MATLAB - Image Edge Detection using Sobel Operator from Scratch -
GeeksforGeeks

You might also like