Lecture 6 - ConnectedComponentsAlgorithm30 01 2023
Lecture 6 - ConnectedComponentsAlgorithm30 01 2023
• Neighborhood
• Adjacency
• Connectivity
• Paths
• Regions and boundaries
Neighbors of a pixel
=
Neighbors of a Pixel (Contd..)
• The points ND(P) and N4(P) are together
known as 8-neighbors of the point P, denoted
by N8(P).
• Some of the points in the N4, ND and N8 may
fall outside image when P lies on the border
of image.
Connectivity
P P P
B(Q) B(Q)
B(Q)
8-Connected
4-Connected
V=(1,2)
M-
Connected
M-connected examples
Set V = { 10, 20,30) Connection between P and Q
is
R 10 40 20 a) 4 connected
Q b) 8 connected
c) m-connected
40 10 40
P
S1 S2
0 0 0 0 0 1 1 0
1 0 0 1 0 1 0 1
1 0 0 1 1 1 0 1
0 0 1 1 0 0 0 0
0 0 1 1 0 0 1 1
S1 S2
0 0 0 0 0 1 1 0
1 0 0 0 0 1 0 1
1 0 0 0 1 1 0 1
0 0 1 1 0 0 0 0
0 0 1 1 0 0 1 1
M –connected & 8
connected
Connected Components
Image I
• Subset s
p
Connected Components
• If p and q are pixels of an image subset S then p is
connected to q in S if there is a path from p to q
consisting entirely of pixels in S.
• For every pixel p in S, the set of pixels in S that are
connected to p is called a connected component of S.
• Distinct connected components are disjoint
Connected component labeling
• Ability to assign different labels to various disjoint
components of an image.
• It facilitates automatic image analysis
• Shape matching
• Area calculation
Algorithm
• Scan the image from left to right
and top to bottom fashion
• Assume 4- connectivity
• ‘A’ be a pixel at any instant of
scanning process. ‘B’ and ‘C’ are
the pixels scanned before scanning
the pixel A.
Steps
Algorithm
l(a) => Pixel value at position A
L(a)=> Label Assigned to pixel location A
If l(a) = 0, move to next scanning position
If l(a)=1 and l(b) = l(c) = 0
then assign a new label to position A
If l(a) =1 and only one of the two neighbor is one
then assign its label to A
If l(a) =1 and both B and C are 1’s ,
then
if l(b) = l(c) than l(a) = l(b)
if l(b) ≠ l(c) then assign one of the labels to A and make a note that
the two labels are equivalent
CCL- Algorithm
C
B A
Connected components labeling
CCL- Algorithm Contd.
1
2 2
Connected components labeling
1
2 2 2
1
2 2 2
Connected components labeling
1
2 2 2
2 2
1
2 2 2
2 2 3
2 4 4
2 4
5 5 5 5
2
2 2 2
2 2 3
2 4 4
2 4
5 5 5 5