Chapter 10
Chapter 10
Similarity (homogeneity)
to partition an image into regions that are
similar according to a set of predefined criteria.
Segmentation based
on
Detection of
Discontinuities
Detection of Discontinuities
There are three basic types of grey level
discontinuities that we tend to look for in digital
images:
1. Points
2. Lines
3. Edges
f(x,y-1)
f(x,y) 2 f
f ( x, y 1) f ( x, y 1) 2 f ( x, y)
y 2
f(x,y+1)
2-Dimensional Laplacian
The digital implementation of the
2-Dimensional Laplacian is obtained by
summing 2 components
2
f 2
f
f 2 2
2
x y
2 f f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1) 4 f ( x, y )
0 1 0
1 -4 1
0 1 0
Mask used to implement an extension of the
Laplacian previous mask. It includes the diagonal
neighbours.
0 1 0 1 1 1
1 -4 1 1 -8 1
0 1 0 1 1 1
1 0 1
0 -4 0
1 0 1
What will be the effect of applying the Laplacian mask on the image
9 9 9 9 9 9 9 2 2
9 8 9 9 9 9 2 2 2
9 9 9 9 9 9 3 2 2
9 9 9 9 9 2 2 2 2
7 9 9 9 9 2 2 2 2
9 9 9 9 2 2 2 2 2
9 9 9 9 2 2 2 4 2
9 9 9 2 2 2 2 2 2
9 9 2 2 2 2 1 2 2
First and Second Order Derivatives
First and Second Order Derivatives …
Analysis
1) The 1st-order derivative is nonzero along the
entire ramp, while the 2nd-order derivative is
nonzero only at the onset and end of the ramp.
2) Edges in an image represent this type (ramp) of
transition. Therefore,
1st make thick edge and 2nd make thin, much
finer edges
3) The response at and around the point is much
stronger for the 2nd- than for the 1st-order
derivative.
1st and 2nd Derivative Comparison
After
Result of
processing
thresholding
with -45° line
filtering result
detector
Edge
The ability to measure gray-level transitions in a
meaningful way
Edges characterize boundaries and are therefore a
problem of fundamental importance in image
processing.
Edges in images are areas with strong intensity
contrasts – a jump in intensity from one pixel to the
next.
Edge detecting in an image significantly reduces the
amount of data and filters out useless information,
while preserving the important structural properties in
an image.
Edge: Example
Edges are caused by a variety of factors
depth discontinuity
illumination discontinuity
Edges are caused by a variety of factors …
Edges are caused by a variety of factors …
Edges are caused by a variety of factors …
Edge detection
Convert a 2D image into a set of curves
Extracts salient features of the scene
More compact than pixels
Problem …
How can you tell that a pixel is on an edge?
Edge detection
Edges can be modeled according to their intensity profiles:
Step edge:
Image intensity abruptly changes from one value to one side of
discontinuity to a different value on opposite side.
Ramp edge:
A step edge where the intensity change is not instantaneous but
occurs over a finite distance.
Roof edge:
A ridge edge where the intensity change is not instantaneous but
occurs over a finite distance.
Profiles of Image Intensity Edges
Difference between an edge & a line???
Noise smoothing
Uncontrolled illumination in &
around the scene
Digital image could have
intensity differential at almost
every point
So some of these insignificant
intensity differentials need to
This is noise
be smoothened out
smoothing
Edge Localization
Noise smoothing has a blurring
effect to some extent on the
intensity map
Edge Linking
process takes an unordered set of edge pixels produced
by an edge detector as i/p to form an ordered list of
edgels
Edge Following
process takes the entire edge strength or gradient image
as i/p & produces geometric primitives such as lines or
curves
Edge Detection (Derivative Operators)
where an edge is
2nd derivative can
be used to show
edge direction
Derivatives & Noise
Derivative based edge detectors are extremely
sensitive to noise
We need to keep this in mind
Intensity profile along a scanline of
Step edge Ramp edge
corrupted with
noise
1 | g ( x, y ) | T
T
f f
Gradient: f e( x, y )
x y 0 otherwise
non edge pixel
Gradient Operators
The gradient of the image I(x,y) at location (x,y), is the
vector:
I x, y
Gx x
I I x, y
G y
y
Gy
The direction of the gradient vector: x, y tan 1
x
G
The Meaning of the Gradient
Let f0 represent f(x,y) i.e. the gray level at pixel (x,y) &
f1 to f8 represent the gray levels of its neighbours.
f1 = f(x-1, y)
Row 1 f2 f1 f8
Row 2 f3 f0 f7 f2 = f(x-1, y-1)
Row 3 f4 f5 f6 & so on
Gradient Operators ...
Ordinary Operator
Therefore,
d1 = f0 – f1 & d2 = f0 – f3
This can be implemented with the following masks
0 -1 0 0
0 1 -1 1
Gradient Operators ...
Roberts Operator
Here,
d1 = f0 – f2 & d2 = f1 – f3
This can be implemented with the following masks
-1 0 0 1
0 1 -1 0
Common Edge Detectors
Given a 3*3 region of an image the following edge
detection filters can be used
Find the strength & the direction of the edge at the
highlighted pixel
y
Pixels in gray have value 0 & in white have
value 1.
θ
θ
Edge
direction
Why do you
think is it
so??
Edges are abrupt discontinuities in
gray levels
Issues to Address
Simple Edge Detection Using Gradients …
Issues to Address
Advanced Techniques
for Edge Detection
image
Canny
Edge smoothing with Gaussian
Detector
differentiating along x and y axis
thresholding
edge map
Algorithm - Canny Edge Detector
Step 1
Convolve the image f(x, y) with a Gaussian function to
get a smooth image f′(x, y).
f′(x, y) = f(x, y) * G(x, y; σ)
Step 2
Apply first difference gradient operator to compute the
edge strength. Any of the filter masks (Roberts, Prewitt
etc.) can be used to calculate d1 & d2.
Algorithm - Canny Edge Detector …
Step 3
Apply non-maximal suppression to the gradient magnitude.
The purpose of this step is to convert the “blurred” edges
in the image of the gradient magnitudes to “sharp”
edges.
This is achieved by suppressing the edge magnitudes not
in the direction of the gradient. In fact, in Cranny’s
approach, the edge direction is reduced to any one of the
four directions.
To perform this task for a given point, its gradient is
compared with that of points of its 3x3 neighbourhood.
If the candidate magnitude is greater than that of its
neighbourhood, the edge strength is maintained, else it is
discarded.
Algorithm - Canny Edge Detector …
Non-Maxima Suppression
Non-maximum suppression:
Select the single maximum point across the width of
an edge.
Algorithm - Canny Edge Detector …
Non-Maxima Suppression
0 0 0 0 1 1 1 3
3 0 0 1 2 1 3 1
0 0 2 1 2 1 1 0
false 0 1 3 2 1 1 0 0
edges 0 3 2 1 0 0 1 3
2 3 2 0 0 1 0 1 gaps
2 3 2 0 1 0 2 1
Algorithm - Canny Edge Detector …
Non-Maxima Suppression …
0 0 0 0 1 1 1 3 local
0 0 0 1 2 1 3 1 maxima
0 0 2 1 2 1 1 0
removed
0 1 3 2 1 1 0 0
0 3 2 1 0 0 1 0 depends
on condition
2 3 2 0 0 1 0 1
2 3 2 0 1 0 2 1
Algorithm - Canny Edge Detector …
Non-Maxima Suppression …
0 0 0 0 0 0 0 3
0 0 0 0 2 1 3 0
0 0 2 1 2 0 0 0
0 0 3 0 0 0 0 0 false edges
0 3 2 0 0 0 0 0
0 3 0 0 0 1 0 1
0 3 0 0 1 0 2 0
The suppressed magnitude image will contain many
false edges caused by noise or fine texture
Algorithm - Canny Edge Detector …
Step 4
Hysteresis thresholding/Edge Linking
threshold T
all values below T are changed to 0
However,
selecting a good values for T is difficult
some false edges will remain if T is too low
some edges will disappear if T is too high
Algorithm - Canny Edge Detector …
Step 5
Hysteresis thresholding/Edge Linking
Canny’s approach employs double thresholding, known as
hysteresis.
In this process, two thresholds, upper & lower
thresholds are set by the user.
For a given edgel chain, if the magnitude of any
one edgel of the chain is greater than the upper
threshold, all edgels above the lower threshold are
selected as edge points.
Algorithm - Canny Edge Detector …
Hysteresis thresholding/Edge Linking
y = mx + c
where m is the slope & c the y-intercept
The equation can be rewritten in c–m space as
c = -xm + y
Suppose we have several edge points (x1, y1), ..., (xn,
yn) in x–y space that we want to fit in a line.
Each point in x–y space maps to a line in c–m
space.
Finding lines in an image
y b
b0
x m0 m
image space Hough space