Ch-3 Image Segmentation
Ch-3 Image Segmentation
Segmentation
• Coordinator (2015)
• Treasurer (2020)
• Executive Committee Member (2015)
1
Segmentation :
☆ Image Segmentation 3
3
☆ Image Segmentation 4
4
2
(1) POINT Detection
Consider a digital subimage F and point detector mask w
F= z1 z2 z3 Point A=
z4 z5 z6 Detector R
z7 z8 z9
w= -1 -1 -1
where,
-1 8 -1
R = z1 w1 + z2 w2 +
-1 -1 -1
z3 w3 + …… + z9 w9
For any point P at (x,y) position,
F= z1 z2 z3 Line A=
z4 z5 z6 Detector R
z7 z8 z9
-1 -1 -1 -1 2 -1 2 -1 -1 -1 -1 2
2 2 2 -1 2 -1 -1 2 -1 -1 2 -1
-1 -1 -1 -1 2 -1 -1 -1 2 2 -1 -1
☆ Image Segmentation 6
6
3
A= 0 0 0
F= 10 10 10 -1Horizontal
-1 -1
100 100 100 2 Line
2 2 540 540 540
Detector W1
10 10 10 -1 -1 -1 0 0 0
F= 10 10 10 -1 2 -1 A= 0 0 0
Vertical Line
100 100 100 -1 2 W-1 0 0 0
Detector 2
10 10 10 -1 2 -1 0 0 0
F= 10 10 10 2 -1 -1 A= 0 0 0
450 Line
100 100 100 -1 2 W-1 0 0 0
Detector 3
10 10 10 -1 -1 2 0 0 0
F= 10 10 10 -1 -1 2 A= 0 0 0
-1 -45 2Line -1
0
100 100 100 0 0 0
Detector W4
10 10 10 2 -1 -1 0 0 0
.
Edge
Dark White
☆ Image Segmentation 8
8
4
[A] Step Edge Detection
(i) Consider a Digital Image
Robert Mask :
F = 0 0 200 200 200 200 0 0
0 0 200 200 200 200 0 0 Gy= -1
-1 11
0 0
0 0 200 200 200 200 0 0
Robert Filter
( 1st Order Derivative Sharpening filter )
-1 0 -1 1
1 0 0 0
☆ Image Segmentation 9
9
[ 0 0 200 0 0 0 -200 0 0 0 ]
☆ Image Segmentation 10
10
5
(iv) The Magnitude of First Order Derivative :
[ 0 0 200 0 0 0 200 0 0 0 ]
F= 0 0 200 0 0 0 200 0 0
0 0 200 0 0 0 200 0 0
0 0 200 0 0 0 200 0 0
6
• Magnitude of second order derivative produces double edges
which is NOT desirable.
Therefore, Second order derivative mask such as Laplacian
mask is NOT suitable to detect Step Edges.
[ 0 0 80 80 80 0 0 0 0 ]
☆ Image Segmentation 14
14
7
(iv) The Magnitude of First Order Derivative :
[ 0 0 80 80 80 0 0 0 0 ]
Thick edge
[ 0 80 0 0 -80 0 0 0 0 ]
[ 0 80 0 0 80 0 0 0 0 ]
☆ Image Segmentation 16
16
8
(v) The Magnitude of Second Order Derivative :
[ 0 80 0 0 80 0 0 0 0 ]
F=
☆ Image Segmentation 18
18
9
• Edge Linking using Local Processing
(i) Consider two edge points A( x1, y1) and B( x2, y2)
as shown in figure below
a) Strength of Gradient
b) Direction of Gradient
☆ Image Segmentation 20
20
10
Edge Linking using Local Processing . . . .
If ≤ Magnitude
Threshold
Where
If ≤ Angle Threshold
Where
☆ Image Segmentation 22
22
11
Edge Linking using Local Processing . . . .
That means,
If ≤ Magnitude
Threshold
AND
≤ Angle Threshold
Then
Two pixels at (x,y) and (x’,y’) can be linked.
Let y = a x + b
12
At A( x1 , y1 ), b = - a x1 + y1
b = -a x + y
At B( x2 , y2 ), b = - a x2 + y2
Y-intercept
(a’,b’) Value
yy b
Y = a’ x + b’ ➔ THIS IS LINE AB
☆ Image Segmentation 26
26
13
(2) Edge Linking using Hough Transform
(I) Map all the input points from xy plane to ab plane
using Hough Transform
e.g. Consider 4 input points A, B, C and D as shown in figure.
yy b
A(x1 , y1)
x a
☆ Dr. Kiran TALELE 27
27
yy b
(D) (A)
A(x1 , y1)
Hough
B(x2 , y2) Transform (C)
(B)
x a
☆ Image Segmentation 28
28
14
(2) Edge Linking using Hough Transform
(I) Map all the input points from xy plane to ab plane
using Hough Transform
e.g. Consider 4 input points A, B, C and D as shown in figure.
b’
yy b
A(x1 , y1) (D) (A)
x a
☆ Image Segmentation 29
29
15
(V) Link all co-linear points
y yy
A A
B B
C C
x x
☆ Image Segmentation 32
32
16
Paul V. C. Hough
The Hough transform was first proposed
by Paul Hough in 1962 as a method for
detecting lines in images.
☆ Image Segmentation 33
33
☆ Image Segmentation 34
34
17
Q1. What is Hough Transform?
35
18
e.g. Cost (A,B) = H - | F(A)-F(B) |
A BB
Assume H = 255
80 80
70 B80
B
Cost = 255-| 70-80| 70 70
70
Cost = 245
Cost = 255-| 70-80| Cost = 255-| 80-70|
Cost = 245 Cost = 245
☆ Image Segmentation 37
37
Example :
Assume that the edge starts in the first Row and ends in the
last row for the following Gray Image.
19
Edge-1 : Edge-2 : Edge-3 : Edge-4 :
5 6 1 5 6 1 5 6 1 5 6 1
6 7 0 6 7 0 6 7 0 6 7 0
7 1 3 7 1 3 7 1 3 7 1 3
5 6 1 5 6 1 5 6 1 5 6 1
6 7 0 6 7 0 6 7 0 6 7 0
7 1 3 7 1 3 7 1 3 7 1 3
☆ Image Segmentation 39
39
7 1 3
20
Cost (A,B) = 7 - | F(A)-F(B) |
(1) For Edge-1 (E1) :
(i) To find C1
5 C1 6 1 C1 = 7 - | F(A)-F(B) |
C1 = 7 - | 5-6 |
6 7 0 C1 = 6
C2
(ii) To find C2
7 C3 1 3 C2 = 7 - | F(A)-F(B) |
C2 = 6
(ii) To find C3
Cost (E1) = C1 + C2 + C3 C3 = 7 - | F(A)-F(B) |
= 6+6+1 C3 = 7 - | 7-1 |
= 13 C3 = 1
☆ Image Segmentation 41
41
5 C1
C1 6 1 5 C1 6 1
C2
6 C2 7 0 6 7 C3 0
7 C3 1 3 7 1 C4 3
21
(3) For Edge-3 (E3) : (4) For Edge-4 (E4) :
5 C1
C1 6 1 5 C1 6 1
C2
6 C2 7 0 6 7 C3 0
C3 C4
7 1 C4 3 7 C5 1 3
☆ Image Segmentation 43
43
5 6 C1 1 5 6 C1 1
C2
6 7 C2 0 6 C3 7 0
7 1 C3 3 7 C4 1 3
22
(7) For Edge-7 (E7) : (8) For Edge-8 (E8) :
5 6 C1 1 5 6 C1 1
C2
6 7 C2 0 6 C3 7 0
C3 C4
7 C4 1 3 7 1 C5 3
☆ Image Segmentation 45
45
For Edge-7 :
5 6 C1 1 5 6 1
6 7 C2 0 6 7 0
C3
7 C4 1 3 7 1 3
23
Edge-7 has the minimum value of Cost.
Therefore, Edge-7 is the most significant edge in the
image
For Edge-7 :
5 6 C1 1 5 6 1
6 7 C2 0 6 7 0
C3
7 C4 1 3 7 1 3
☆ Image Segmentation 47
47
5 6 C1 1 5 7 0
6 7 C2 0 6 7 0
C3
7 C4 1 3 7 1 3
24
Edge-7 has the minimum value of Cost.
Therefore, Edge-7 is the most significant edge in the
image
5 6 C1 1 0 7 0
6 7 C2 0 0 7 0
C3
7 C4 1 3 7 0 0
☆ Image Segmentation 49
49
5 6 C1 1 0 7 0
6 7 C2 0 0 7 0
C3
7 C4 1 3 7 0 0
☆ Image Segmentation 50
50
25
Edge-7 has the minimum value of Cost.
Therefore, Edge-7 is the most significant edge in the
image
5 6 1 0 7 0
6 7 0 0 7 0
7 1 3 7 0 0
☆ Image Segmentation 52
52
26
(A) Region Growing by Pixel Aggregation :-
Example-1 : F= 0
1 2 3
0 1 2 3
F= 0 1 2 3
0 4 5 6
0 1 2 3
4 5 6 7
0 4 5 6
4 5 6 7
1 2 3
F= 0
0 1 2 3
Predicate :
If F(x,y) = { 0, 1, 2, 3 } 0 4 5 6
Then F(x,y) = Red 4 5 6 7
Else F(x,y) = Yellow
☆ Image Segmentation 54
54
27
Ex-2: Segment the following given image using
Region Growing by Pixel Aggregation.
Assume Threshold=2.
Predicate :
7
Let Seed Point be S(x’,y’)
If | F(x,y) –S(x’,y’) | ≤ T 5
Then F(x,y) = Intensity of
Segmented
Region
☆ Image Segmentation 56
56
28
Step-2 : Let Seed Point S2(0,0) = 3 and T = 2
0 1 2 3 4 5 6 7
Predicate : 0 3
B 3B 2B 4B 2B 1B 4
A 3
A
If | F(x,y) – S2 (0,0) | ≤ T 1 B
1 5B 3
B B
2 7
A A
5 6
A A
4
i.e. | F(x,y) – 3 | ≤ 2 2 B
2 B
1 B
2 A
6 A
4 A
7 3
A A
5
i.e. F(x,y) = { 1, 2, 3, 4, 5 } 3 4
A 5
A 6
A 7
A A
7 6
A 2 0
4 A
4 5
A A
6 A
7 A
4 0 3 2
5 A
7 A
7 6
A 5
A 2 3 3 1
Then F(x,y) = B 6 1 1 0 0 3 1 2 1
7 2 3 4 3 3 4 3 2
Segmented Region : R2 = { B }
No of Segmented Regions : 3
R = R 1 U R2 U R3
☆ Image Segmentation 58
58
29
(B) Region Splitting & Merging :-
In this method,
• First an image is subdivided into a set of
regions and
• Then subdivided adjacent regions are
merged to form a new region.
By Splitting : By Merging :
10 10 80 80 10 10 80 80
10 10 80 80
10 10 80 80
50 50 80 80
50 50 80 80
50 50 80 80
50 50 80 80
☆ Image Segmentation 60
60
30
Ex-2 : Segment the following given image such that the
difference between the Maximum intensity value and
the minimum intensity value in the segmented region
is less than 8 using Region Splitting & Merging
Technique
10 9 30 4
7 6 33 37
50 52 54 53
55 52 56 58
Predicate for Splitting:
For Any Region R ;
IF | Max Intensity Value – Min Intensity Value | ≥ 8
Then Split the region into 4 parts
R1 R2 R
R R3 R4
R1 R2 R3 R4
☆ Image Segmentation 62
62
31
(1) For Input Image R 10 9 30 4
7 6 33 37
Imax = 58 Imin = 4
Imax – Imin = 54 ≥ 8 50 52 54 53
55 52 56 58
Predicate (R) = TRUE
So, Split the region R into 4 parts
R1 R2 10 9 30 4
R R3 R4 7 6 33 37
50 52 54 56
R 55 52 56 58
R1 R2 R3 R4 .
R2 = R21 R22 30 4
R23 R24 33 37
☆ Image Segmentation 64
64
32
(4) For Region R3 R1 R2 10 9 30 4
7 6 33 37
Imax = 55 Imin = 50 R3 R4
Imax – Imax = 5 50 52 54 56
55 52 56 58
Predicate (R) = FALSE
Imax – Imax = 4 50 52 54 56
Result of Splitting
R21 R22 10 9 30 4
R R1
R23 R24 7 6 33 37
50 52 54 56
R3 R4 55 52 56 58
R
R1 R2 R3 R4 .
☆ Image Segmentation 66
66
33
Step-1 : Region Merging
Predicate for Merging
Let MAB = RA U RB
50 52 54 56
Imax = 33 Imin = 30 R3 R4 55 52 56 58
Imax – Imax = 3 < 8
Predicate = TRUE
Merge the regions R22 10 9 30 4
R1 M1
R24 7 6 33 37
Let M1 = { R21 U R23 } 50 52 54 56
R3 R4
55 52 56 58
☆ Image Segmentation 68
68
34
2. For { M1 U R24 } R22 10 9 30 4
R1 M1
R24 7 6 33 37
Imax = 37 Imin = 30
Imax – Imax = 7 < 8 R3 R4
50 52 54 56
55 52 56 58
Predicate = TRUE
Merge the regions
R22 10 9 30 4
Let M2 = { M1 U R24 } R1 M2
7 6 33 37
50 52 54 56
R3 R4
55 52 56 58
3. For { R3 U R4 } R22 10 9 30 4
R1 M2
7 6 33 37
Imax = 56 Imin = 50
Imax – Imax = 6 < 8 50 52 54 56
R3 R4
Predicate = TRUE 55 52 56 55
50 52 54 56
M3
55 52 56 55
☆ Image Segmentation 70
70
35
Result of Segmentation :
1) No of Segmented Regions = 4
Such that R = R1 U R22 U M2 U M3
10 9 30 4 R2 A A C B
R1
7 6 33 37 M2 A A C C
50 52 54 53 D D D D
M3
55 52 56 55 D D D D
Stay Connected
72
72
36
• Dr. Kiran TALELE is an Associate Professor in Electronics &
Telecommunication Engineering Department of Bharatiya Vidya Bhavans’
Sardar Patel Institute of Technology, Mumbai with 33+ years experience in
Academics.
• His area of research is Digital Signal & Image Processing, Computer Vision,
Machine Learning and Multimedia System Design.
• He is a Treasurer of IEEE Bombay Section and Mentor for Startup Incubation &
Intellectual Asset Creation.
73
37