Professional Documents
Culture Documents
Castleman
Castleman
1
What is Image Segmentation?
Image segmentation is to divide an image into
parts that have a strong correlation with
objects or areas of the real world contained in
the image. (Watt )
2
Image Processing Flow based on
Image Segmentation
Image Feature
Classification
Segmentation Extraction
3
Why is it difficult?
In general autonomous ( 自 主 的 )
segmentation is one of the most difficult
tasks in image processing. It is difficult beca
use of many reasons. Here are some typical
obstacles:
Non-uniform illumination
No control of the environment
Inadequate model of the object of interest
Noise
etc. 4
Principal approaches
Segmentation methods can be divided into three groups
according to the dominant features they employ.
Segmentation based on global knowledge about an image;
― The knowledge is usually represented by a histogram of
image features.
Edge-based segmentations;
― Utilizing edge detection processes to find a closed
boundary so that an inside and an outside can be
defined.
Region-based segmentations;
― This techniques proceed by dividing the image into
regions that exhibit similar properties.
5
2 basis properties of intensity values
6
Detection of Discontinuities
detect the three basic types of gray level
discontinuities
points , lines , edges
7
Contents
Thresholding
Point Detection
Line Detection
Edge-based Segmentation
Region-based Segmentation
8
7.1 Thresholding
Thresholding is a labeling operation on a
gray scale image that distinguishes pixels of
a higher intensity from pixels with a lower
intensity value.
The output of thresholding usually is a
binary image.
This technique is particularly useful for
scenes which contain solid objects on a
uniform contrasting background.
9
Classification of Thresholding
Thresholding can be viewed as an operation
that involves tests against a function T of t
he form:
T T x , y, p x, y , f x , y
10
Classification of Thresholding
When T depends on
only f(x,y) : only on gray-level values
Global thresholding
both f(x,y) and p(x,y) : on gray-level values and
its neighbors
Local thresholding
x and y (in addition)
Dynamic thresholding
T T x , y, p x, y , f x , y
11
Basic Global Thresholding
See “basic_global_thre.m”
Solution
Solution:: use
use TT midway
midway between
between the
the max
max and
and min
min
gray
gray levels
levels
12
Basic Global Thresholding
Let light objects in dark background
To extract the objects:
Select a “T” that separates the objects from th
e background
i.e. any (x,y) for which f(x,y)>T is an object poi
nt.
A thresholded image:
1 if f x , y T background
g x, y
0 if f x , y T foreground
13
Heuristic Global Thresholding
1. Select an initial estimate for T.
See “Adaptive_threshold.m”
15
Multilevel Thresholding
to background if f(x,y) ≤ T1 16
The histogram of an image containing two pr
incipal brightness regions can be considered
an estimate of the brightness probability de
nsity function p(z).
p(z) is the sum (or mixture) of two unimodal ( 单
峰的 ) densities (one for light, one for dark regio
ns).
p z P1 p1 z P2 p2 z
P1 P2 1
17
Optimal Thresholding
If the form of the
densities is known
or assumed, in
terms of minimum
error, determining
an optimal
p z P1 p1 z P2 p2 z
threshold for
P2 1
P1segmenting the
image is possible.
18
Optimal Thresholding
Probability of erroneously
19
Optimal Thresholding
Minimum error
Differentiating ( 微 分 ) E(T) with respect to T
(using Leibniz’s rule) and equating the result to 0
20
Optimal Thresholding
Minimum error
21
Optimal Thresholding
For example,
Let PDF=Gaussian density : p1(z) and p2(z)
23
Problems of Thresholding
24
Problems of Thresholding
26
7.2 Point Detection
Note that the mark is the same as the mas
k of Laplacian Operation (in chapter 3)
1 1 1 0 1 0
1 8 1 1 4 1
1 1 1 0 1 0
28
7.3 Line Detection
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
Horizontal 45 Vertical 45
Horizontal mask will result with max response when
a line passed through the middle row of the mask
with a constant background.
the similar idea is used with other masks.
Note: the preferred direction of each mask is
weighted with a larger coefficient (i.e.,2) than
other possible directions. 29
Idea 1 of Line Detection
Apply every masks on the image
let R1, R2, R3, R4 denotes the response of the
horizontal, +45 degree, vertical and -45 degree
masks, respectively.
|Ri|>|Rj|,
for all j≠i, that point is said to be more lik
ely associated with a line in the direction of
mask i.
30
Idea 2 of Line Detection
Alternatively, if we are interested in detect
ing all lines in an image in the direction defi
ned by a given mask, we simply run the mas
k through the image and threshold the absol
ute value of the result.
32
7.4 Edge-based Segmentation
Edge-based segmentations rely on edges
found in an image by edge detecting
operators
these edges mark image locations of
discontinuities in gray level
Edge detection is the most common approach for
detecting meaningful discontinuities in gray level
because of
optics, sampling,
image acquisition
imperfection
36
Thick and Thin Edge
The slope of the ramp is inversely proportional to
the degree of blurring in the edge.
Namely, we no longer have a thin (one pixel thick) path.
Gray-level
profile
First
derivate
an undesirable feature
produces 2 values for every edge in an image
zero-crossing property
an imaginary straight line joining the extreme
positive and negative values of the second
derivative would cross zero near the midpoint of
the edge.
quite useful for locating the centers of thick
edges.
39
Basic idea of edge detection
A profile is defined perpendicularly to the
edge direction and the results are
interpreted.
The magnitude of the first derivative is used to
detect an edge (if a point is on a ramp)
40
Review of First Derivate z1 z2 z3
z4 z5 z6
Gradient Operator: f G x G y
z7 z8 z9
simplest approximation, 22
G x z6 z5 G y z8 z5
Roberts cross-gradientoperators, 22
1 0 0 1
G x z9 z 5 G y z8 z 6
0 1 1 0
Sobel operators, 33
G x z7 2 z8 z9 z1 2 z 2 z3
1 2 1 1 0 1
G y z3 2 z6 z9 z1 2 z 4 z7 0 0 0 2 0 2
1 2 1 1 0 1
41
Edge direction and strength
Let α(x,y) represents the direction angle of
the vector f at (x,y)
α(x,y)=tan-1(Gy/Gx)
The direction of an edge at (x,y) perpendic
ular ( 垂直 ) to the direction of the gradient
vector at that point
The edge strength is given by the gradient
magnitude
f G x G y
2 2
42
Gradient Masks
1 2 1 1 0 1
1 0 0 1
0 0 0 2 0 2
0 1 1 0
1 2 1 1 0 1
Roberts
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
43
Diagonal edges with Prewitt
and Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt 44
Review of Second Derivate
Laplacian Operator
f x 1, y f x 1, y
f
2
f x , y 1 f x , y 1 4 f x , y
0 1 0 1 1 1
Laplacian 1 4 1 1 8 1
Mask 0 1 0 1 1 1
45
Example of edge detection
See Matlab Help--demo--toolbox--image p
rocessing--analysis…--Edge detection
r 2
2
r 2
h
2
exp 2
2
4
r 2 x2 y2
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to zero
49
Edge Detection and Segmentation
Image resulting from edge detection cannot
be used as a segmentation result.
50
7.5 Region-based Segmentation
Goal: find regions that
PPare “homogeneous”
((RRi)i) is
is aa logical b
logical predicate
predicate
y some criterion property defined
property defined over
over the
the
points in
points set RRi
in set
Segmentation is a process that partitions R
i
For example, PP((RRi)i) == TRUE
For example, TRUE
into n subregions R1, R2, …, Rn such that:
if all
if all pixel in RRi i have
pixel in have the
the ss
ame gray
ame gray level
level
51
Two methods of Region Segmentation
Region Growing
Region Splitting
52
Region Growing
The objective of segmentation is to
partition an image into regions
A region is a connected component with some
uniformity (say gray-levels or texture)
55
Example: defective welds ( 焊缝 ) detecting
56
Criterion:
There is a valley at around 190 in the histogram.
A pixel should have a value>190 to be considered
as a part of region to the seed point.
The pixel should be a 8-connected neighbor to at
least one pixel in that region
59
Region Splitting and Merging
Procedure:
60
Region Splitting and Merging
Quadtree
( 四叉树 )
61
Example