21JE0854 DIP Assignment
21JE0854 DIP Assignment
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
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.
Gradient image typically contains wide ridges around local maxima. The next step is to thin
those ridges.
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.
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:
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.
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.