EDGE DETECTION
➢ Edge detection is the process of finding meaningful
transitions in an image.
➢ Edge detection is one of the central tasks of the lower levels
of image processing.
➢ The points where sharp changes in the brightness occur
typically form the border between different objects.
➢ These points can be detected by computing intensity
differences in local image regions.
➢ That is, the edge-detection algorithm should look for a
neighbourhood with strong signs of change.
➢ Most of the edge detectors work on measuring the
intensity gradient at a point in the image.
Importance of Edge Detection
➢ The purpose of edge detection is to identify areas of an image where
a large change in intensity occurs.
➢ These changes are often associated with some physical boundary in
the scene from which the image is derived.
➢ In typical images, edges characterise object boundaries and are
useful for segmentation, registration and identification of objects in a
scene.
Gradient Operator
A gradient is a two-dimensional vector that points to the direction in
which the image intensity grows fastest.
The gradient operator ∇ is given by
If the operator ∇ is applied to the function f then
❖ The two functions that can be expressed in terms of the directional
derivatives are the gradient magnitude and the gradient
orientation.
❖ It is possible to compute the magnitude f of the gradient and the
orientation φ(∇f ).
The gradient magnitude gives the amount of the difference between
pixels in the neighbourhood which gives the strength of the edge. The
gradient magnitude is defined by
The magnitude of the gradient gives the maximum rate of increase of
f (x, y) per unit distance in the gradient orientation of ∇f .
The gradient orientation gives the direction of the greatest change,
which presumably is the direction across the edge.
The gradient orientation is given by
where the angle is measured with respect to the x-axis.
➢The direction of the edge at (x, y) is perpendicular to the direction of
the gradient vector at that point.
➢Figure indicates the gradient of the edge pixel.
➢The circle indicates the location of the pixel.
➢An edge pixel is described using two important features:
(i) Edge strength, which is equal to the magnitude of the gradient
(ii)Edge direction, which is equal to the angle of the gradient
Edge Detection Using First-order Derivatives
❑ The derivative of a digital pixel grid can be defined in terms of
differences.
❑ The first derivative of an image containing gray-value pixels
must fulfill the following conditions—it must be zero in flat
segments, i.e. in area of constant gray-level values; it must be
non-zero at the beginning of a gray-level step or ramp; and it
must be non-zero along the ramp (constant change in gray
values).
❑ The first-order derivative of a one-dimensional function f (x) can
be obtained using
➢ Pixel discontinuity can be determined along eight possible
directions such as up, down, left, right and along the four
diagonals.
➢ The other method of calculating the first-order derivative is
given by estimating the finite difference:
The finite difference can be approximated as
and
Using the pixel coordinate notation and considering that j corresponds to the
direction of x, and i corresponds to the y direction, we have
➢ Most edge-detecting operators can be thought of as gradient
calculators.
➢ Because the gradient is a continuous function concept and the
input signal is a finite signal (image), the gradient computations
have to be approximated.
• Roberts Kernel
• Prewitt Kernel
• Sobel Kernel
Second-Derivative Method of Detecting Edges in an Image
❑Finding the ideal edge is equivalent to finding the point where the
derivative is maximum or minimum.
❑The maximum or minimum value of a function can be computed by
differentiating the given function and finding places where the derivative is
zero.
❑Differentiating the first derivative gives the second derivative.
❑Finding the optimal edges is equivalent to finding places where the second
derivative is zero.
❑The differential operators can be applied to images; the zeros rarely fall
exactly on a pixel.
❑The problems with zero-crossing methods are the following:
(i) Zero crossing methods produce two-pixel thick edges.
(ii) Zero crossing methods are extremely sensitive to noise.
The operator ∇⋅∇ = ∇2 is called the Laplacian operator. The
Laplacian operator when applied to the function f, we get
The Laplacian operation can be expressed in terms of difference
equations as given below:
The 3 × 3 Laplacian operator is given by
❑ The Laplacian operator subtracts the brightness values of each of the
neighbouring pixels from the central pixel.
❑ When a discontinuity is present within the neighbourhood in the
form of a point, line or edge, the result of the Laplacian is a non-zero
value.
❑ It may be either positive or negative depending where the central
point lies with respect to the edge
Drawbacks of the Laplacian Operator
The main drawbacks of the Laplacian operator are summarised
below:
1.Useful directional information is not available by the use of a
Laplacian operator.
2.The Laplacian, being an approximation to the second
derivative, doubly enhances any noise in the image
Laplacian of Gaussian (LOG)
❑ A prominent source of performance degradation in the Laplacian
operator is noise in the input image.
❑ The noise effects can be minimised by smoothing the image prior
to edge enhancement.
❑ The Laplacian-of Gaussian (LOG) operator smooths the image
through convolution with a Gaussian-shaped kernel followed by
applying the Laplacian operator.
❑ The sequence of operation involved in an LOG operator is given
below
Laplacian of Gaussian (LOG)
The Gaussian mask is given by
On differentiating the Gaussian kernel, we get
Disadvantages of LOG Operator
The LOG operator being a second-derivative operator, the influence of noise is
considerable. It always generates closed contours, which is not realistic.
Canny Edge Detector
❑ One problem with a Laplacian zero-crossing as an edge detector is that it
simply adds the principal curvatures together.
❑ That is, it does not really determine the maximum of the gradient
magnitude.
❑ The Canny edge detector defines edges as zero-crossings of second
derivatives in the direction of the greatest first derivative.
❑ The Canny operator works in a multi-stage process. First, the image is
smoothed by a Gaussian convolution.
❑ Then, a 2D first derivative operator is applied to the smoothed image to
highlight regions of the image with high spatial derivatives.
❑ Edges give rise to ridges in the gradient magnitude image.
❑ The Gaussian smoothing in the Canny edge detector fulfills two
❑ purposes. First, it can be used to control the amount of detail that
appears in the edge image, and second, it can be used to suppress noise
Canny Edge Detector
clear all;
close all; clc; a=imread(image.jpg);
a=rgb2gray(a);
b=edge(a, roberts);
c=edge(a, sobel);
d=edge(a, prewitt);
e=edge(a, log);
f=edge(a, canny);
imshow(a), title(Original Image)
Fig., imshow(b), title(Roberts)
Fig., imshow(c), title(Sobel)
Fig., imshow(d), title(Prewitt)
Fig., imshow(e), title(Log)
Fig., imshow(f), title(Canny)