Professional Documents
Culture Documents
Application Dependent
3
of
20
The Segmentation Problem
Segmentation attempts to partition the pixels
of an image into groups that strongly
correlate with the objects in an image
Typically the first step in any automated
computer vision application
1
Example :
Example : Regions Straight Lines
8 9
2.similarity:
To partition an image into regions that are similar according to
a set of predefined criteria.
Regions are found based on SIMILARITIES between values of
adjacent pixels.
10 11
2
Background
First-order derivative
f
f '( x) f ( x 1) f ( x)
x
Second-order derivative
f
2
f ( x 1) f ( x 1) 2 f ( x)
x 2
12 13
3
Detection of Isolated Points Detection of Isolated Points
18 19
4
Line Detection Line Detection
Second derivatives to result in a stronger response and
to produce thinner lines than first derivatives
5
Edge Detection
the most common approach for detecting
meaningful discontinuities in gray level.
we discuss approaches for implementing
first-order derivative (Gradient operator)
second-order derivative (Laplacian operator)
Here, we will talk only about their
properties for edge detection.
we have introduced both derivatives
24 25
because of optics,
sampling, image
acquisition
26 imperfection 27
6
Thick edge First and Second derivatives
The slope of the ramp is inversely proportional to the
degree of blurring in the edge.
We no longer have a thin (one pixel thick) path.
Instead, an edge point now is any point contained in the
ramp, and an edge would then be a set of such points
that are connected.
The thickness is determined by the length of the ramp.
The length is determined by the slope, which is in turn
determined by the degree of blurring.
the signs of the derivatives
Blurred edges tend to be thick and sharp edges
would be reversed for an edge
tend to be thin
that transitions from light to
dark
28 29
30 31
7
Noise Images Keep in mind
First column: images and
gray-level profiles of a fairly little noise can have such a
ramp edge corrupted by significant impact on the two key
random Gaussian noise of
mean 0 and = 0.0, 0.1, derivatives used for edge detection in
1.0 and 10.0,
respectively. images
Second column: first-
derivative images and
image smoothing should be serious
gray-level profiles. consideration prior to the use of
Third column : second- derivatives in applications where noise is
derivative images and
gray-level profiles. likely to be present.
32 33
Edge point
to determine a point as an edge point Basic Edge Detection by Using First-
the transition in grey level associated with Order Derivative
the point has to be significantly stronger
than the background at that point.
use threshold to determine whether a value
is “significant” or not.
the point’s two-dimensional first-order
derivative must be greater than a specified
threshold.
34 35
8
f
Gx x
f f
Gradient Operator G y
y
Gradient direction
first derivatives are implemented using Let (x,y) represent the direction angle
the magnitude of the gradient. of the vector f at (x,y)
(x,y) = tan-1(Gy/Gx)
1
f mag (f ) [Gx2 G y2 ] 2
commonly approx.
f 2 f 2
1
2 The direction of an edge at (x,y) is
perpendicular to the direction of the
x y gradient vector at that point
f Gx G y
the magnitude becomes nonlinear
36 37
38 39
9
Example
40 42
43
10
Example (using Prewitt
operator) Another Example
d
I
dx
Note: in this example, the
divisions by 2 and 3 in the
computation of fx and fy
are done for normalization
purposes only
d
I
dy
Isotropic property of
Another Example (cont’d) gradient magnitude
22
d d
22
Threshold 100
11
Practical Issues Practical Issues (cont’d)
Noise suppression-localization tradeoff. • Choice of threshold.
Smoothing depends on mask size (e.g., depends gradient magnitude
on σ for Gaussian filters).
Larger mask sizes reduce noise, but worsen
53
12
positive central term
surrounded by an adjacent negative region (a function of distance)
zero outer region
Laplacian of Gaussian Mexican hat
Laplacian combined with smoothing as a
precursor to find edges via zero-
crossing.
where r2 = x2+y2, and
r2 is the standard deviation
h( r ) e 2 2
r2
r 2 2 2 2
2 h( r ) e
4
54
the coefficient must be sum to zero
55
56 57
13
Zero crossing & LoG Zero crossing vs. Gradient
Approximate the zero crossing from LoG Attractive
image Zero crossing produces thinner edges
to threshold the LoG image by setting all Noise reduction
its positive values to white and all Drawbacks
negative values to black. Zero crossing creates closed loops.
the zero crossing occur between positive (spaghetti effect)
and negative values of the thresholded sophisticated computation.
LoG. Gradient is more frequently used.
58 59
e 2 2
2 e 2
x 2 y
x2 y 2 x2 y 2
x2 1 y2 1
4 2 e 2 2
4 2 e 2 2
x2 y 2
x2 y2 2
e
2 2
4 60 61
14
Marr-Hildreth Algorithm
1. Filter the input image with an nxn Gaussian lowpass
filter.
g ( x, y) 2 G( x, y) f ( x, y)
62 63
The Canny Edge Detector The Canny Edge Detector: Algorithm (1)
Optimal for step edges corrupted by white noise. Let f ( x, y ) denote the input image and
G ( x, y ) denote the Gaussian function:
The Objective
x2 y 2
1. Low error rate G ( x, y ) e 2 2
15
The Canny Edge Detector: Algorithm(2) The Canny Edge Detector: Algorithm(3)
Compute the gradient magnitude and direction (angle): The gradient M ( x, y ) typically contains wide ridge around
M ( x, y ) g x 2 g y 2 local maxima. Next step is to thin those ridges.
and Nonmaxima suppression:
( x, y ) arctan( g y / g x ) Let d1 , d 2 , d3 , and d 4 denote the four basic edge directions for
where g x f s / x and g y f s / y a 3 3 region: horizontal, -45o , vertical,+45 , respectively.
1. Find the direction d k that is closest to ( x, y ).
Note: any of the filter mask pairs in Fig.10.14 can be used 2. If the value of M ( x, y ) is less than at least one of its two
to obtain g x and g y neighbors along d k , let g N ( x, y ) 0 (suppression);
otherwise, let g N ( x, y ) M ( x, y )
66 67
Hysteresis thresholding:
g NH ( x, y ) g N ( x, y ) TH
g NL ( x, y ) g N ( x, y ) TL
68 69
16
The Canny Edge Detector: Algorithm(5) The Canny Edge Detection: Summary
Depending on the value of TH , the edges in g NH ( x, y ) Smooth the input image with a Gaussian filter
typically have gaps. Longer edges are formed using
the following procedure: Compute the gradient magnitude and angle images
(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 ) Apply nonmaxima suppression to the gradient
magnitude image
that are connected to p using 8-connectivity.
(c). If all nonzero pixel in g NH ( x, y ) have been visited go to Use double thresholding and connectivity analysis to
step (d), esle return to (a). detect and link edges
(d). Set to zero all pixels in g NL ( x, y ) that were not marked as
valid edge pixels. 70 71
17
74 75
76 77
18
Criteria Criteria
1. the strength of the response of the 2. the direction of the gradient vector
gradient operator used to produce the an edge pixel with coordinates (x0,y0) in a
edge pixel predefined neighborhood of (x,y) is similar
an edge pixel with coordinates (x0,y0) in a in angle to the pixel at (x,y) if
predefined neighborhood of (x,y) is similar
in magnitude to the pixel at (x,y) if
78 79
19
Hough Transformation (Line) Accumulator cells
(amax, amin) and (bmax, bmin) are
the expected ranges of slope
and intercept values.
all are initialized to zero
if a choice of ap results in
solution bq then we let
A(p,q) = A(p,q)+1
xy-plane ab-plane or parameter space at the end of the procedure,
yi =axi + b b = - axi + yi value Q in A(i,j) corresponds
to Q points in the xy-plane
all points (xi ,yi) contained on the same line must have lines in lying on the line y = aix+bj b = - axi + yi
parameter space that intersect at (a’,b’) 82 83
-plane
-plane
x cos + y sin =
= 90 measured with respect to x-axis
problem of using equation y = ax + b is that value of a is infinite
for a vertical line.
To avoid the problem, use equation x cos + y sin = to
represent a line instead.
vertical line has = 90 with equals to the positive y-intercept
or = -90 with equals to the negative y-intercept
84 85
20
Generalized Hough
Transformation Hough Transformation (Circle)
can be used for any function of the form equation:
(x-c1)2 + (y-c2)2 = c32
g(v,c) = 0
three parameters (c1, c2, c3)
v is a vector of coordinates cube like cells
c is a vector of coefficients accumulators of the form A(i, j, k)
increment c1 and c2 , solve of c3 that satisfies
the equation
update the accumulator corresponding to the
cell associated with triplet (c1, c2, c3)
86 87
21
Thresholding
image with dark image with dark
background and background and
a light object two light objects
link criteria:
1). the pixels belonged to one of the set of pixels
linked according to the highest count
2). no gaps were longer than 5 pixels
90 91
92
22
easily use global thresholding
object and background are separated
23
Basic Global Thresholding Example: Heuristic method
based on visual inspection of histogram note: the clear valley
1. Select an initial estimate for T. of the histogram and
2. Segment the image using T. This will produce two the effective of the
groups of pixels: G1 consisting of all pixels with gray segmentation
level values > T and G2 consisting of pixels with gray between object and
level values T
background
3. Compute the average gray level values 1 and 2 for
the pixels in regions G1 and G2
4. Compute a new threshold value
T = 0.5 (1 + 2) T0 = 0
5. Go to [2] until the difference in values of T is small 3 iterations
enough. with result T = 125
98 99
100 101
24
Optimal Global and Adaptive
Further subdivision Thresholding
a). Properly and improperly
segmented subimages from previous
example
b)-c). corresponding histograms
d). further subdivision of the
improperly segmented subimage.
e). histogram of small subimage at
top
f). result of adaptively segmenting d).
p( z ) P1 p1 ( z ) P2 p2 ( z )
102
P1 P2 1 103
dE (T ) d ( P2 E1 (T ) P1 E2 (T ))
T 0
E2 (T ) p ( z )dz
1
dT dT if P = P then 1 2
the optimum threshold
is where the curve
p1(z) and p2(z) intersect
E(T ) P2 E1 (T ) P1E2 (T ) find T which makes
P1 p1 (T ) P2 p2 (T )
104 105
25
Gaussian density Quadratic equation
Example: use PDF = Gaussian density : p1(z) and p2(z)
AT 2 BT C 0
where A 12 22
p( z ) P1 p1 ( z ) P2 p2 ( z )
( z 1 ) 2 ( z 2 )2 B 2( 1 22 2 12 )
P1 P2
e 2 12
e 2 22
C 12 22 22 12 2 12 2 22 ln( 2 P1 / 1 P2 )
where 2 1 2 2 if P1 = P2 or = 0
• 1 and 12 are the mean and variance of the Gaussian 1 2 2 P then the optimal
density of one object T ln 2 threshold is the
• 2 and 22 are the mean and variance of the Gaussian 2 1 2 P1 average of the
density of the other object 106 means 107
108 109
26
Boundary Characteristic for
Example: Histogram Improvement and Local
Boundary superimposed Thresholding
light object of dark background
0 if f T
s ( x , y ) if f T and 2 f 0
if f T and 2 f 0
local processing due to using gradient of each small area
(…)(-,+)(0 or +)(+,-)(…)
all pixels that are not on an edge are labeled 0
all pixels that are on the dark side of an edge are
labeled +
all pixels that are on the light side an edge are labeled -
110 111
112 113
27
Result of applying T Region-Based Segmentation
Basicn Formulation
(a) Ri R
i 1
28
Histogram of fig 10.40 a) Region splitting and merging
Example
29