Advanced Techniques for
Edge Detection
Mar-Hildreth Edge Detection
Canny Edge Detection
Advanced Techniques for Edge
Detection
The Marr-Hildreth edge detector
x2 y 2
G ( x, y ) e 2 2
, : space constant.
Laplacian of Gaussian (LoG)
2
G ( x , y ) 2
G ( x, y )
2 G ( x, y )
x 2 y 2
x 2 2 y x y2
2 2 2 2
x y
2e 2 e 2
x y
x2 y 2 x2 y 2
x 2
1 y 1
2
4 2 e 2 2
4 2 e 2 2
x2 y 2
x y
2 2 2
e 2 2
4
08/27/2021 2
08/27/2021 3
Marr-Hildreth Algorithm
1. Filter the input image with an nxn Gaussian
lowpass filter. N is the smallest odd integer
greater
than or equal to 6
2. Compute the Laplacian of the image resulting
from step1
3. Find the zero crossing of the image from step 2
g ( x, y ) G ( x, y ) f ( x, y )
2
08/27/2021 4
08/27/2021 5
Quiz Qn : 1
Need for advanced Edge Detection
Techniques?
1st and second derivatives are more sensitive
to noises. They fail to detect edges in noisy
images.
Characteristics of edges such as orientations,
are not considered
08/27/2021 6
Quiz Qn : 2
Intensity changes are independent of image
scale. Yes or No?
Answer : NO
08/27/2021 7
Quiz Qn : 3
What are the two salient features of an edge
detection operator?
Should be a differential operator
Should be capable of being tuned to act at
any desired scale.
08/27/2021 8
Quiz Qn : 4
Large operators are used to detect blurry
edges and small operators are used to detect
sharply focussed fine details. Yes or No?
Answer : YES
08/27/2021 9
Quiz Qn : 5
What is the operator which satisifes the two
salient features of an edge detection
operator?
ANS:
It is called as _____
Ans: Laplacian of Gaussion (LoG)
It is also called as _______
Ans: Mexican hat operator
08/27/2021 10
Quiz Qn : 6
What are two fundamental ideas in selecting
the LoG operator?
ANS:
G – blurs the image so that the noise content
is reduced
- isotropic operator
What is an isotropic operator?
Ans: Invariant to rotation
08/27/2021 11
Quiz Qn : 7
What is invariant to rotation?
Not only responds equally to changes in
intensity in any mask direction
Benefit?
We need not use multiple masks to calculate
strongest response at any point in the image
08/27/2021 12
Quiz Qn : 8
What is the size of the Gaussian Filter with
respect to σ ?
ANS: smallest odd ineger, greater than or
equal to 6σ
Ex: σ=3 , n= ?
Ex: σ=4 , n= ?
Ex: σ=5 , n= ?
08/27/2021 13
The Canny Edge Detector
Optimal for step edges corrupted by white noise.
The Objective and steps
1. Low error rate
The edges detected must be as close as possible to the true
edge
2. Edge points should be well localized
The edges located must be as close as possible to the true
edges
3. Single edge point response
The number of local maxima around the true edge should
be minimum
08/27/2021 14
The Canny Edge Detector: Algorithm (1)
Let f ( x, y ) denote the input image and
G ( x, y ) denote the Gaussian function:
x2 y 2
G ( x, y ) e 2 2
We form a smoothed image, f s ( x, y ) by
convolving G and f :
f s ( x , y ) G ( x, y ) f ( x, y )
08/27/2021 15
The Canny Edge Detector: Algorithm(2)
Compute the gradient magnitude and direction (angle):
M ( x, y ) g x 2 g y 2
and
( x, y ) arctan( g y / g x )
where g x f s / x and g y f s / y
Note: any of the filter mask pairs in Fig.10.14 can be used
to obtain g x and g y
08/27/2021 16
The Canny Edge Detector: Algorithm(3)
The gradient M ( x, y ) typically contains wide ridge around
local maxima. Next step is to thin those ridges.
Nonmaxima suppression:
Let d1 , d 2 , d3 , and d 4 denote the four basic edge directions for
a 3 3 region: horizontal, -45o , vertical,+45 , respectively.
1. Find the direction d k that is closest to ( x, y ).
2. If the value of M ( x, y ) is less than at least one of its two
neighbors along d k , let g N ( x, y) 0 (suppression);
otherwise, let g N ( x, y ) M ( x, y )
08/27/2021 17
08/27/2021 18
The Canny Edge Detector: Algorithm(4)
The final operation is to threshold g N ( x, y ) to reduce
false edge points.
Hysteresis thresholding:
g NH ( x, y ) g N ( x, y ) TH
g NL ( x, y ) g N ( x, y ) TL
and
g NL ( x, y ) g NL ( x, y ) g NH ( x, y )
08/27/2021 19
The Canny Edge Detector: Algorithm(5)
Depending on the value of TH , the edges in g NH ( x, y )
typically have gaps. Longer edges are formed using
the following procedure:
(a). Locate the next unvisited edge pixel, p, in g NH ( x, y ).
(b). Mark as valid edge pixel all the weak pixels in g NL ( x, y )
that are connected to p using 8-connectivity.
(c). If all nonzero pixel in g NH ( x, y ) have been visited go to
step (d), esle return to (a).
(d). Set to zero all pixels in g NL ( x, y ) that were not marked as
valid edge pixels.
08/27/2021 20
The Canny Edge Detection: Summary
Smooth the input image with a Gaussian filter
Compute the gradient magnitude and angle images
Apply nonmaxima suppression to the gradient
magnitude image
Use double thresholding and connectivity analysis
to detect and link edges
08/27/2021 21
TL 0.04; TH 0.10; 4 and a mask of size 25 25
08/27/2021 22
TL 0.05; TH 0.15; 2 and a mask of size 13 13
08/27/2021 23
08/27/2021 24
08/27/2021 25
Region Based
Segmentation
Example 1: Regions
27
Example 2:
Straight Lines
28
Example 3:
Lines and Circular Arcs
29
Region Segmentation:
Segmentation Criteria
A segmentation is a partition of an image I into
a set of regions S satisfying:
1. Partition covers the whole image.
2. Si Sj = , i j No regions intersect.
3. Si, P(Si) = true Homogeneity predicate is
satisfied by each region.
4. P(Si Sj) = false, Union of adjacent regions
i j, Si adjacent Sj does not satisfy it.
30
So
So all we have to do is define and implement the
similarity predicate.
But, what do we want to be similar in each region?
Is there any property that will cause the regions to
be meaningful objects?
31
•IMAGE SEGMENTATION TECHNIQUES
IMAGE SEGMENTATION TECHNIQUES
Segmentation divides an image into its constituent
regions or objects.
Image segmentation means assigning a label to each pixel
in the image such that pixels with same labels share
common visual characteristics.
It makes an image easier to analyze in the image
processing tasks.
Segmentation of images is a difficult task in image
processing.
Still under research.
Segmentation allows to extract objects in images.
Segmentation is unsupervised learning.
Model based object extraction, e.g., template matching, is
supervised learning.
32
WHAT IT IS USEFUL FOR
After a successful segmenting the image, the contours of
objects can be extracted using edge detection and/or
border following techniques.
Shape of objects can be described.
Based on shape, texture, and color, objects can be
identified.
Image segmentation techniques are extensively used in
similarity searches
33
CATEGORIES OF SEGMENTATION TECHNIQUES
◦ EDGE-BASE SEGMENTATION
◦ REGION-BASED SEGMENTATION
34
Detecting Discontinuity :
◦ It means to partition an image based on abrupt changes
in intensity
◦ This includes image segmentation algorithms like edge
detection.
Detecting Similarity:
◦ It means to partition an image into regions that are
similar according to a set of predefined criterion
◦ This includes image segmentation algorithms like
thresholding, region growing.
35
EDGE-BASED SEGMENTATION
Segmentation Methods based on Discontinuity
It finds for abrupt changes in the intensity value.
These methods are called as Edge or Boundary
based methods.
Edge detection is the problem of fundamental
importance in image analysis.
Edge detection techniques are generally used for
finding discontinuities in gray level images.
Edge detection is the most common approach for
detecting meaningful discontinuities in the gray
level.
36
EDGE-BASED SEGMENTATION
Image segmentation methods for detecting discontinuities
are boundary based methods.
Edge detection can be done using either of the following
methods.
Edges are local changes in the image intensity. Edges
typically occur on the boundary between two regions.
Important features can be extracted from the edges of an
image (e. g., corners, lines, curves). Edge detection is an
important feature for image analysis.
37
REGION-BASED SEGMENTATION
Region based methods are based on continuity.
These techniques divide the entire image into
sub regions depending on some rules like all the
pixels in one region must have the same gray
level.
Region-based techniques rely on common
patterns in intensity values within a cluster of
neighboring pixels.
The cluster is referred to as the region, and the
goal of the segmentation algorithm is to group
the regions according to their anatomical or
functional roles.
38
REGION-BASED SEGMENTATION
Compared to edge detection method, segmentation
algorithms based on region are relatively simple and
more immune to noise.
Edge based methods partition an image based on
rapid changes in intensity near edges whereas region
based methods, partition an image into regions that
are similar according to a set of predefined criteria
39
SEGMENTATIONALGORITHMS BASEDON REGION
MAINLY INCLUDE FOLLOWING METHODS:
Region Growing
Region Splitting and Merging
40
SEGMENTATIONALGORITHMS BASEDON REGION
MAINLY INCLUDE FOLLOWING METHODS:
Region Growing
Region growing is a procedure that group’s pixels
in whole image into sub regions or larger regions
based on predefined criterion
41
SEGMENTATIONALGORITHMS BASEDON REGION
Region Splitting and Merging
Rather than choosing seed points, user can divide
an image into a set of arbitrary unconnected
regions and then merge the regions in an attempt
to satisfy the conditions of reasonable image
segmentation.
Region splitting and merging is usually
implemented with theory based on quad tree data.
42
Main Methods of Region
Segmentation
1. Region Growing
2. Split and Merge
43
Edge Linking and Boundary Detection
Edge detection typically is followed by linking
algorithms designed to assemble edge pixels into
meaningful edges and/or region boundaries
Three approaches to edge linking
Local processing
Regional processing
Global processing
08/27/2021 44
Local Processing
Analyze the characteristics of pixels in a small
neighborhood about every point (x,y) that has been
declared an edge point
All points that similar according to predefined
criteria are linked, forming an edge of pixels.
Establishing similarity: (1) the strength (magnitude)
and (2) the direction of the gradient vector.
A pixel with coordinates (s,t) in Sxy is linked to the
pixel at (x,y) if both magnitude and direction
criteria are satisfied.
08/27/2021 45
Local Processing
Let S xy denote the set of coordinates of a neighborhood
centered at point (x, y ) in an image. An edge pixel with
coordinate (s, t ) in S xy is similar in magnitude to the pixel
at (x, y ) if An edge pixel with coordinate (s, t ) in S xy is similar in angle
to the pixel at (x, y) if
( s , t ) ( x, y ) A
M ( s , t ) M ( x, y ) E
08/27/2021 46
Local Processing: Steps (1)
1. Compute the gradient magnitude and angle
arrays, M(x,y)
( x, yand
) , of the input image
f(x,y)
2. Form a binary image, g, whose value at any pair
of coordinates (x,y) is given by
1 if M ( x, y ) TM and ( x, y ) A TA
g ( x, y )
0 otherwise
TM : threshold A : specified angle direction
TA : a "band" of acceptable directions about A
08/27/2021 47
Local Processing: Steps (2)
3. Scan the rows of g and fill (set to 1) all gaps (sets
of 0s) in each row that do not exceed a specified
length, K.
4. To detect gaps in any other direction, rotate g by
this angle and apply the horizontal scanning
procedure in step 3.
08/27/2021 48
08/27/2021 49
Regional Processing
The location of regions of interest in an image are
known or can be determined
Polygonal approximations can capture the essential
shape features of a region while keeping the
representation of the boundary relatively simple
Open or closed curve
Open curve: a large distance between two
consecutive points in the ordered sequence relative
to the distance between other points
08/27/2021 50
08/27/2021 51
Regional Processing: Steps
1. Let P be the sequence of ordered, distinct, 1-valued
points of a binary image. Specify two starting points,
A and B.
2. Specify a threshold, T, and two empty stacks, OPEN
and ClOSED.
3. If the points in P correspond to a closed curve, put A
into OPEN and put B into OPEN and CLOSES. If the
points correspond to an open curve, put A into OPEN
and B into CLOSED.
4. Compute the parameters of the line passing from the
last vertex in CLOSED to the last vertex in OPEN.
08/27/2021 52
Regional Processing: Steps
5. Compute the distances from the line in Step 4 to all
the points in P whose sequence places them
between the vertices from Step 4. Select the point,
Vmax, with the maximum distance, Dmax
6. If Dmax> T, place Vmax at the end of the OPEN stack as
a new vertex. Go to step 4.
7. Else, remove the last vertex from OPEN and insert it
as the last vertex of CLOSED.
8. If OPEN is not empty, go to step 4.
9. Else, exit. The vertices in CLOSED are the vertices of
the polygonal fit to the points in P.
08/27/2021 53
08/27/2021 54
08/27/2021 55
08/27/2021 56
Variable Thresholding Based on Local
Image Properties
Let xy and mxy denote the standard deviation and mean value
of the set of pixels contained in a neighborhood S xy , centered
at coordinates (x, y ) in an image. The local thresholds,
Txy a xy bmxy
If the background is nearly constant,
Txy a xy bm
1 if f ( x, y ) Txy
g ( x, y )
0 if f ( x, y ) Txy
08/27/2021 57
Region-Based Segmentation
Region Growing
1. Region growing is a procedure that groups pixels or subregions
into larger regions.
2. The simplest of these approaches is pixel aggregation, which
starts with a set of “seed” points and from these grows regions
by appending to each seed points those neighboring pixels that
have similar properties (such as gray level, texture, color, shape).
3. Region growing based techniques are better than the edge-
based techniques in noisy images where edges are difficult to
detect.
08/27/2021 58
Region-Based Segmentation
Example: Region Growing based on 8-connectivity
f ( x, y ) : input image array
S ( x, y ): seed array containing 1s (seeds) and 0s
Q( x, y ): predicate
08/27/2021 59
Region Growing based on 8-connectivity
1. Find all connected components in S ( x, y) and erode each
connected components to one pixel; label all such pixels
found as 1. All other pixels in S are labeled 0.
2. Form an image fQ such that, at a pair of coordinates (x,y),
let fQ ( x, y ) 1 if the Q is satisfied otherwise f Q ( x, y ) 0.
3. Let g be an image formed by appending to each seed point
in S all the 1-value points in f Q that are 8-connected to that
seed point.
4. Label each connencted component in g with a different region
label. This is the segmented image obtained by region growing.
08/27/2021 60
TRUE if the absolute difference of the intensities
Q between the seed and the pixel at (x,y) is T
FALSE otherwise
08/27/2021 61
08/27/2021 62
4-connectivity
08/27/2021 63
8-connectivity
08/27/2021 64
08/27/2021 65
08/27/2021 66
Region Splitting and Merging
R : entire image Ri :entire image Q: predicate
1. For any region Ri , If Q( Ri ) = FALSE,
we divide the image Ri into quadrants.
2. When no further splitting is possible,
merge any adjacent regions R j and Rk
for which Q( R j Rk ) = TRUE.
3. Stop when no further merging is possible.
08/27/2021 67
08/27/2021 68
08/27/2021 69
TRUE if a and 0 m b
Q
FALSE otherwise
08/27/2021 70
END