IVP Unit-V & VI
IVP Unit-V & VI
1
Principal approaches
➢ Segmentation is to subdivide an image into its
component regions or objects.
2
Detection of Discontinuities
➢ Detect the three basic types of gray-level discontinuities
❖Points , lines , edges
➢ The common way is to run a mask through the image
3
Point Detection
➢ A point has been detected at the location on which the
mark is centered if
|R| T
➢ where
❖T is a non-negative threshold
❖R is the sum of products of the coefficients with the gray
levels contained in the region encompassed by the mark.
Laplacian Operation
4
Example
5
Line Detection
7
Example
After processing
with -45° line Result of
detector thresholding
filtering result
9
Edge Detection -Ideal and Ramp Edges
11
First and Second derivatives
13
First column: images and gray-level profiles of a ramp edge corrupted by random Gaussian
noise of mean 0 and = 0.0, 0.1, 1.0 and 10.0, respectively
First Derivative Second Derivative
14
Notes
15
Gradient Operator
f
➢ First derivatives are implemented using
Gx x
the magnitude of the gradient. f = = f
G y
1
y
f = mag (f ) = [G + G ] 2
x
2
y
2
1
f f
2 2 2
= + commonly approx.
x y
the magnitude becomes nonlinear
f Gx + G y
The direction of the gradient vector is the angle
α(x,y) given by
17
Gradient Masks
18
Diagonal edges with Prewitt
and Sobel masks
19
Example
Original Image Horizontal Gradient Component
21
Edge linking and boundary detection
22
Edge linking: local processing
➢ Basic idea:
❖Analyze the characteristics of pixels in a small neighborhood
(3x3,5x5, etc) for every point (x,y) that has undergone edge
detection
❖All points that are “similar” are linked, forming a boundary of
pixels that share some common property
➢ Two principal properties for establishing similarity
❖The strength of the response of the gradient operator used to
produce the edge pixels
1
f = mag (f ) = [G + G ]
2
x
2
y
2
23
Edge linking: local processing (cont.)
➢ An edge pixel at (x’,y’) in the neighborhood centered at
(x,y) is similar in magnitude to the pixel at (x,y) if
24
Thresholding
➢ Thresholding is the simplest segmentation method.
➢ The pixels are partitioned depending on their intensity value.
➢ Global thresholding, using an appropriate threshold T:
27
Thresholding based on boundaries
➢ Important aspect of threshold selection: the ability to
reliably identify mode peaks in a given histogram
➢ The chances of selecting a “good” threshold are
enhanced if mode peaks are
❖tall
❖narrow
❖symmetric
❖and separated by deep valleys
➢ One approach for improving the histogram shape is to
consider only those pixels that lie on or near a boundary
between objects and the background
28
Choosing Thresholding
image with dark background and a light object image with dark background and two light
objects
Peaks and valleys of the image histogram can help in choosing the appropriate
value for the threshold(s).
Some factors affects the suitability of the histogram for guiding the choice of the
threshold:
• the separation between peaks;
• the noise content in the image;
• the relative size of objects and background;
• Illumination and reflection
29
Noise role in Thresholding
30
easily use global thresholding
object and background are separated
The Role of Illumination
illumination: reflectance:
Slow spatial variations vary abruptly, particularly
at the junctions of dissimilar
objects
33
Otsu’s method
Total pixels
• uses the gray scale
histogram of an image
• separates two regions
with maximum inter-
class variance.
34
➢ Select a threshold T(k)= k, 0<k<L-1,
❖Two classes, c1 and c2 , where c1 (intensity values in the
range [0, k]) and c2 Pixels in [k+1, L-1]
➢ The probability, P1(k ), that a pixel is assigned to class
c1 is given by the cumulative sum
➢ Similarly
35
➢ Mean intensity value of the pixels assigned to class c2 is
➢ Hence
36
Once k* has been obtained, input image f (x,y) is segmented
37
Problem
38
39
40
Region-Based Segmentation
❖ Region growing
41
Basic Formulation
➢ Let R represent the entire image region.
➢ Segmentation is a process that partitions R into subregions,
R1,R2,…,Rn, such that
42
Region Growing
➢ The basic approach is to start with a set of “seed” points
➢ Groups pixel or subregions into larger regions based on a predefined criteria from a set
of “seed” points.
➢ Growing by appending to each seed those neighbors that have similar properties such as
➢ Several key factors: the selection of “seed” points, similarity criteria, descriptor (based
on intensity levels, such as moments or texture, and spatial properties), stop rule,
adjacency definition.
➢ The selection of the seeds can be operated manually or using automatic procedures
44
➢ (a) X-ray image of a defective weld
f.
➢ (b) Histogram.
➢ (c) Initial seed image S.
➢ (d) Final seed image (erosion).
➢ (e) Absolute value of the difference
between the seed value (255) and
(a) (|f-S|).
➢ (f) Histogram of (e).
➢ (g) Difference image thresholded
using dual thresholds.
➢ (h) |f-S|>68
➢ (i) Segmentation result obtained by
region growing Q:=|f-S| <=68
45
➢ Criteria:
46
47
The segmented region
48
2 2 7 2 1 Consider the 3-bit image.
1 7 6 6 2 Assume seed value is 6.
segment using 8-connectivity
7 6 6 5 7
and threshold is 3.
2 4 5 4 2
1 2 5 1 1
49
Region Splitting and Merging
50
51
Region Splitting
➢ The main problem with region splitting is determining
where to split a region.
➢ One method to divide a region is to use a quadtree
structure.
➢ Quadtree: a tree in which nodes have exactly four
descendants.
52
5 6 6 6 7 7 6 6
Consider the 3-bit image.
6 7 6 7 5 5 4 7 Assume the threshold value
6 6 4 4 3 2 5 6 <=4.
5 4 5 4 2 3 4 6
0 3 2 3 3 2 4 7
0 0 0 0 2 2 5 6
1 1 0 1 0 3 4 4
1 0 1 0 2 3 5 4
53
Region Splitting and Merging
54
➢ Here we define P(Ri) = TRUE if at least 80% of the
pixels in Ri have the property:
❖|zj – mi| ≤ 2σi , where zj is the gray level of the jth pixel in
Ri , mi is the mean gray level of that region,
❖σi is the standard deviation of the gray levels in Ri.
❖If P(Ri)=TRUE under this condition, the values of all the
pixels in Ri were set equal to mi.
55