0% found this document useful (0 votes)
13 views7 pages

21JE0854 DIP Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

21JE0854 DIP Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Assignment

Digital Image Processing

Name: Seera Sai Tarun


ADMNO: 21JE0854
Course code: (ECD402)
Instructor: Prof Debjani Mitra
Department of Electronics Engineering
IIT (ISM) Dhanbad
Canny Edge Detection
Edge pixels are pixels at which the intensity of an image changes abruptly, and edges are sets of
connected edge pixels. Edge detectors are local image processing tools designed to detect edge
pixels. A line may be viewed as a (typically) thin edge segment in which the intensity of the
background on either side of the line is either much higher or much lower than the intensity of
the line pixels. Among various edge detection methods, the Canny Edge Detector is one of the
most widely used edge detector.

The below three properties describe the ideal characteristics of an edge detector and are crucial
for accurately detecting edges in an image:

Low Error Rate - The edge detector should detect all real edges present in the image. It should
avoid detecting false edges. If an edge detector misses edges, important details in the image will
be lost. If it detects non-existent edges, noise and irrelevant details will interfere with object
recognition.

Edge Points Should Be Well Localized - The detected edge points should be as close as possible
to the actual edges in the image. The distance between a detected edge and the true edge should
be minimal

Single Edge Point Response - For a given real edge, the detector should mark only one edge
pixel, not multiple adjacent ones. If multiple edge pixels are detected for a single edge, the result
will look thicker than the real edge.

The Canny Edge Detection Algorithm consists of four major steps aiming to meet the above
three criteria

Step 1: Noise Reduction using Gaussian Filter


Since edge detection is susceptible to noise, the first step is to smooth the image using a
Gaussian filter. Let f (x, y) denote the input image, G (x, y) denote the Gaussian function and
fs (x, y) be the smoothed image, then
The image can be processed by using a circular 2-D Gaussian function to smooth out the image first. This
can be implemented by using an n ×n Gaussian kernel. A typical 5x5 Gaussian kernel is:

After smoothing, the gradient will be calculated and the resultant gradient’s magnitude and direction will
be utilized to estimate the strength of the edge and its direction at each corresponding point in the next
step.

Step 2: Compute the Gradient (Edge Strength and Direction)


Edges are regions of high intensity change. We compute gradients using Sobel operators:

The gradient magnitude is calculated as

And the edge direction (θ) is

Gradient image typically contains wide ridges around local maxima. The next step is to thin
those ridges.

Step 3: Non-Maximum Suppression (Thinning the Edges)


To thin the ridges, one approach is to use non-maxima suppression. The essence of this approach
is to specify a number of discrete orientations of the edge normal (gradient vector). To get thin
edges, we retain only the local maxima by comparing a pixel's gradient magnitude with its
neighbours along the gradient direction and suppressing pixels that are not local maxima.

For example, in a 3 ×3 region we can define four orientations for an edge passing through the
center point of the region: horizontal, vertical, + 45° and −45 °. Because we have to quantize all
possible edge directions into four ranges.

Let d1, d2, d3, and d4 and denote the four basic edge normal directions for a 3 x 3 box area:
horizontal, -45 degrees, vertical, and +45 degrees, respectively.

For a 3 x 3 box region situated at an arbitrary location (x, y) in angle θ, we can devise the
following non-maxima suppression procedure:

1. Determine which of the angles dk is the closest to θ (x, y) derived from the preceding step.
2. Assuming that K is equal to M(x, y) of one or both of the neighbours of point (x, y). If K is
less than M(x, y) in the direction of dk, set gN(x, y) = 0 (suppression); otherwise, gN(x, y)= K

When repeated for all values of x and y, this procedure yields a non-maximum suppressed image
gN (x, y). This resulting image contains only the thinned edges.

Step 4: Double Thresholding (Strong and Weak Edges)


To minimise erroneous edge points, gN(x, y) is thresholded as the last step.

We accomplished this with the Marr-Hildreth algorithm by setting a single threshold to 0 for all
values below it. There will still be some false edges, also known as false positives, if the
threshold is set too low. False negatives, or legitimate edge points, will be deleted if the
threshold is set very high.
Canny's technique uses hysteresis thresholding in an effort to improve this circumstance. It uses
two thresholds: a low threshold, TL and a high threshold, TH.
The edges can be classified as:
• Strong Edges: Pixels with gradient > High Threshold (definitely edges).
• Weak Edges: Pixels with gradient between Low and High Threshold.
• Non-edges: Pixels with gradient < Low Threshold.

Hysteresis thresholding involves 2 thresholds TL and Th who are in the ratios of 1:2 to 1:3 by
experiments. We can visualize the thresholding operation as creating two additional images:

One generates longer edges by following this process:

a) Find the next unposed edge pixel, p, in gNH(x, y).


b) Mark all the weak pixels in gNL(x, y) connected to p using, say, 8-connectivity as legitimate
edge pixels.
c) Go to Step (d) if every nonzero pixel in gNH(x, y) has been seen. Alternatively, go back to
Step ( a).
(d) Sets every pixel in gNL(x, y) that were not marked as valid edges to zero.

Appending to gNH(x, y) all the nonzero pixels from gNL(x, y) generates the last image created
by the Canny technique at end. To help to simplify the conversation, we included two more
images: gNH(x, y) and gNL(x, y).

Practically, hysteresis thresholding can be applied straight during non-maxima suppression and
immediately on gN(x, y) by creating a list of strong pixels and the weak pixels related to them.
Although the edges after non-maxima suppression are thinner than raw gradient edges, the
former can still be thicker than one pixel. To obtain edges one pixel thick, it is typical to follow
Step 4 with one pass of an edge-thinning algorithm

After applying double thresholding, the image contains strong edges (which are definitely part
of edges) and weak edges (which might or might not be part of real edges). The goal of edge
tracking by hysteresis is to eliminate weak edges that are not connected to strong edges,
ensuring that only meaningful edges remain.

How Edge Tracking Works


1. Keep strong edges: Pixels marked as strong edges (gradient magnitude > high threshold)
remain in the final edge map.
2. Check weak edges: For each weak edge pixel, check if it is connected to a strong edge
in an 8-connected neighbourhood (left, right, top, bottom, and diagonals).
o If a weak edge pixel is connected to a strong edge, it is promoted to a strong
edge.
o If it is not connected to any strong edge, it is suppressed (removed).
3. Remove isolated weak edges: Pixels that do not have a strong edge neighbour are
discarded.

a)Original image b) Thresholded gradient of the smoothed image c) Image obtained by Marr-Hildreth algorithm d) Image
obtained by Canny algorithm
In order to accomplish the goals given in the earlier paragraph regarding the gradient and Marr-Hildreth
images. Looking at the Canny image together with the other two, I notice in the Canny results evident
enhancements in the details of the principal edges, and at the same time, more rejection of irrelevant
features. For instance, the Canny algorithm was able to detect both edges of the concrete band
surrounding the bricks, but the trimmed gradient lost both of these edges, and the Marr-Hildreth method
only detected the upper one. Also, the Canny image is the one that does not contain a single edge owing
to the roof tiles; in the other two images this is not accurate. The quality of the lines in the Canny image is
also the best in continuity, thinness, and straightness. Such results have made the Canny algorithm a tool
of choice due to its effectiveness in edge detection.

References:
• Canny, J. (1986). A Computational Approach to Edge Detection. IEEE Transactions on
Pattern Analysis and Machine Intelligence, PAMI-8(6), 679-698.

• Gonzalez, R. C., & Woods, R. E. (2018). Digital Image Processing (4th Edition). Pearson.

• Canny Edge Detection - Computerphile:


https://www.youtube.com/watch?v=sRFM5IEqR2w

You might also like