M-4 Image Segmentation
M-4 Image Segmentation
Image
Segmentation
1. R.C. Gonzalez and R.E. Woods, Digital Image Processing, Second Edition, Pearson
Education 3rd edition 2008
2. R.C. Gonzalez, R.E. Woods and S.L. Eddins, Digital Image Processing using Matlab,
McGraw Hill,2nd Edition
L-15 Detection of discontinuities, edge
linking and boundary detection
• Region Growing
• Region split and merging
R w1 z1 w2 z2 ... w9 z9 wi zi
i1
Point Detection
The detection of isolated point different from constant background image can
be done using the following mask:
-1 -1 -1
-1 8 -1
-1 -1 -1
• A point has been detected at the location on which the mask is centered if |
R|>T where T is non negative threshold and.
• The idea is that the gray level of an isolated point will be quite different
from the gray levels of its neighbors.
• The mask operation measures the weighted differences between the centre
point and its neighbors. The differences that are large enough are
determined by T considered isolated points in the image of interest.
Detection of Discontinuities
Point Detection
RT
where T : a nonnegative threshold
Line Detection
• Only slightly more common than point detection is to find a one pixel wide line in
an image.
• For digital images the only three point straight lines are only horizontal, vertical, or
diagonal (+ or –45degree).
• If the horizontal mask is moved around an image it would respond more strongly to
lines oriented horizontally.
• With constant background the maximum response would result when the line is passing
through the middle row of the mask.
• The various masks present for line detection are :
Detection of Discontinuities
Line Detection
Edge Detection:
First-order derivatives:
• – The gradient of an image f(x,y) at location (x,y)
is defined as the vector:
f
f G x
x
f
Gy y
–
The magnitude of this vector:
f mag(f ) G G 2
x
2
y
1
2
1 G x
– The direction of this vector: (x, y)
tan G y
– It points in the direction of the greatest rate of
change of f at location (x,y)
Detection of Discontinuities
Gradient Operators
Detection of Discontinuities
Gradient Operators
Prewitt operators
Sobel operators
Detection of Discontinuities
Gradient Operators
f Gx Gy
Detection of Discontinuities
Gradient Operators: Example
Detection of Discontinuities
Gradient Operators: Example
Detection of Discontinuities
Gradient Operators: Example
Detection of Discontinuities
Gradient Operators
Second-order derivatives: (The Laplacian)
•
– The Laplacian of an 2D function f(x,y) is defined
as 2 f 2
2 f f
y2
x 2
– Two forms in
practice:
L-15
More Advanced Techniques for Edge Detection
e 2 G(x, y) 2 G(x, y)
2 G(x, y)
x2 y2
y2 x2 y 2
2
x
G(x, y)
2 x y
e 2 2
2 e 2 2
x 2
y
x2 y 2 x2 y 2
G(x, y) x 4 12 y 1
2 2
2 2 2
2 2
e
4 2 e
x y 2 2
2
2 G(x, y) x y 2 2
2 2 2
e
4
This expression is called Laplacian of a Gaussion
(LoG)
More Advanced Techniques for Edge Detection
Detection of Discontinuities
Gradient Operators: Example
Sobel gradient
The major problem with this algorithm is that it does not work
for vertical lines, as they have a slope of infinity
Convert line into polar coordinates ρ = x cosӨ + ysinӨ, where Ө is the
Edge Linking and Boundary Detection
Global Processing via the Hough Transform
2,3,4
1,4
Edge Linking and Boundary Detection
Hough Transform Example
L-16
Thresholding
• Global
• Adaptive
Thresholding
Thresholding is a phenomenon which occurs due to
extreme contrast stretching. In the contrast stretching
diagram if we make the first and the last slope zero
(r1=r2=0) and we increase the center slope, we will get a
thresholding transformation.
s=0; if r<=a
s=L−1; if r\gta
where L is the number of grey levels.
Thresholding
Suppose that an image, f(x,y), is composed of light objects on a
dark background, and the following figure is the histogram of the
image.
if f (x, y)
g(x, y)
1
0 T f f (x, y)
T
When T is a constant applicable over an entire image, then the
above process is called as Global thresholding.
Thresholding
When the value of T changes over an image
Then that process is referred as Variable thresholding.
Sometimes it is also termed as local or regional thresholding.
Where, the value of T at any point (x,y) in an image depends
on properties of a neighborhood of (x,y).
If T depends on the spatial coordinates (x,y) themselves, then
variable thresholding is often referred to as dynamic or
adaptive thresholding.
Thresholding
Thresholding
Multilevel Thresholding
It is also possible to extract objects that have a specific intensity
range using multiple thresholds.
image with dark background
and two light objects
– to background if f(x,y) T1
a
g(x, y) b if T1 f (x, y) 2
T ifc if f (x, y) 1
T
Thresholding
Thresholding
Role of Noise in Image
Thresholding
Role of Illumination in Image
Thresholding
Non-uniform illumination may change the histogram in a
way that it becomes impossible to segment the image using
a single global threshold.
Choosing local threshold values may help.
Role of Illumination in Image
Thresholding
Basic Global Thresholding
Based on visual inspection of histogram
1. Select an initial estimate for T.
2. Segment the image using T. This will produce two groups of pixels: G1
consisting of all pixels with gray level values > T and G2 consisting of
pixels with gray level values T
3. Compute the average gray level values 1 and 2 for the pixels in
regions G1 and G2
4. Compute a new threshold value
5. T = 0.5 (1 + 2)
6. Repeat steps 2 through 4 until the difference between the values
of T in successive iterations is smaller than a predefined parameter ΔT.
Basic Global Thresholding
Region-based Segmentation..
Region-Based Segmentation
•It states that a region is coherent if all the pixels of that region are
homogeneous with respect to some characteristics such as colour,
intensity, texture, or other statistical properties
•Selection of the initial seed: Initial seed that represent the ROI should
be given typically by the user. Can be chosen automatically. The seeds
can be either single or multiple
•Assume seed point indicated by underlines. Let the seed pixels 1 and 9
represent the regions C and D, respectively
•If the difference is less than or equal to 4 (i.e. T=4), merge the pixel
with that region. Otherwise, merge the pixel with the other region.
Split and Merge Algorithm
Region Growing
criteria:
1. the absolute gray-
level difference
between any pixel
and the seed has to
be less than 65
2. the pixel has to be 8-
connected to at
least
one pixel in that
region (if more, the
regions are merged)
select all seed points with gray
level 255
Region Growing
criteria:
1. the absolute gray-level
difference between any pixel
and the seed has to be less
than 65
2. the pixel has to be 8-
connected to at least one
pixel in that region (if more,
the regions are merged)
Region-Based Segmentation
Region Growing
•This process is repeated for each quadrant until all the regions meet the
required homogeneity criteria. If the regions are too small, then the
division process is stopped.
•1) Split and continue the subdivision process until some stopping
criteria is fulfilled. The stopping criteria often occur at a stage where no
further splitting is possible.
•2) Merge adjacent regions if the regions share any common criteria.
Stop the process when no further merging is possible
Region-Based Segmentation
Region Splitting and
Merging
• Region splitting is the opposite of region growing.
– First there is a large region (possible the
entire image).
– Then a predicate (measurement) is used
to determine if the region is uniform.
– If not, then the method requires that the
region be split into two regions.
– Then each of these two regions is
independently tested by the predicate
(measurement).
– This procedure continues until all resulting
Region-Based Segmentation
Region Splitting
• –Split into four disjoint quadrants any region Ri for which P(Ri) =
FALSE.