You are on page 1of 6

LAB#09

Edge detection
Edge:
Sudden changes of discontinuities in an image are called as edges. Significant
transitions in an image are called as edges.

Types of edges

Generally edges are of three types:

 Horizontal edges
 Vertical Edges
 Diagonal Edges

Derivative Mask:  
All the masks that are used for edge detection are also known as derivative masks. All
the derivative masks should have the following properties:

 Opposite sign should be present in the mask.


 Sum of mask should be equal to zero.
 More weight means more edge detection.

Prewitt operator:
It is used for edge detection in an image. It detects two types of edges

 Horizontal edges
 Vertical Edges
Edges are calculated by using difference between corresponding pixel intensities of an
image. For vertical edges, the mask is
When you will convolve this mask on an image, it will give you the vertical edges in an
image.
Sobel: The major difference is that in sobel operator the coefficients of masks are not
fixed and they can be adjusted according to our requirement unless they do not violate
any property of derivative masks. if we apply more weight to the mask, the more edges
it will get for us.
Example#1

Example#2

Canny edge Detector: The Canny edge detection algorithm is composed of 4 steps:

1. Noise reduction;

2. Gradient calculation;

3. Non-maximum suppression;

4. Double threshold , Edge Tracking by Hysteresis

This Algorithm is based on grayscale pictures. Therefore, the pre-requisite is to convert


the image to grayscale before following the above-mentioned steps.

Noise reduction: One way to get rid of the noise on the image, is by applying Gaussian
blur to smooth it. To do so, image convolution technique is applied with a Gaussian
Kernel (3x3, 5x5, 7x7 etc…). The kernel size depends on the expected blurring effect.
Basically, the smallest the kernel, the less visible is the blur.

Gradient calculation: It detects the edge intensity and direction by calculating the

gradient of the image using edge detection operators. When the image is smoothed, the

derivatives Ix and Iy w.r.t. x and y are calculated. It can be implemented by

convolving I with Sobel kernels Kx and Ky, respectively:


Sobel filters for both direction (horizontal and vertical)

Then, the magnitude G and the slope θ of the gradient are calculated as follow:

Gradient intensity and Edge direction

Non-maximum suppression:
Ideally, the final image should have thin edges. Thus, we must perform non-maximum
suppression to thin out the edges. After getting gradient magnitude and direction, a full
scan of image is done to remove any unwanted pixels which may not constitute the
edge. For this, at every pixel, pixel is checked if it is a local maximum in its
neighborhood in the direction of gradient. Check the image below:

Point A is on the edge ( in vertical direction). Gradient direction is normal to the edge.
Point B and C are in gradient directions. So point A is checked with point B and C to see
if it forms a local maximum. If so, it is considered for next stage, otherwise, it is
suppressed ( put to zero).

In short, the result you get is a binary image with “thin edges”.
Double threshold :The double threshold step aims at identifying 3 kinds of pixels:
strong, weak, and non-relevant:

 Strong pixels are pixels that have an intensity so high that we are sure they

contribute to the final edge. intensity higher than the high threshold

 Weak pixels are pixels that have an intensity value that is not enough to be

considered as strong ones, but yet not small enough to be considered as non-

relevant for the edge detection. intensity lower than the low threshold

 Other pixels are considered as non-relevant for the edge. All pixels having intensity

between both thresholds are flagged as weak and the Hysteresis mechanism 

You might also like