Today's Contents: Basics Relationships Between Pixels
Today's Contents: Basics Relationships Between Pixels
▪ Adjacency
▪ Connectivity
▪ Distance
Chapter 2 from R.C. Gonzalez and R.E. Woods, Digital Image Processing
(3rd Edition), Prentice Hall, 2008 [ Section 2.5 ] [Problems: 2.9 ~ 2.17
excluding 2.14]
Pixel and their Relationships
Conventional indexing method of Pixels
(0,0)
x
y (x-1,y) (x , y) (x+1,y)
❑ Neighbors of a pixel
❑ 3 types of neighbors
❑ N4(p): 4-neighbor of p
❑ ND(p): diagonal neighbor of p
❑ N8(p): 8-neighbor of p
4
N4(p): 4-neighbor of p
❑considers only vertical and horizontal neighbors
pixels.
❑ Note: q ∈ N4(p) implies p ∈ N4(q)
(x,y-1)
4-neighbors of p:
(x−1,y)
(x-1,y) p (x+1,y) (x+1,y)
N4(p) (x,y−1)
(x,y+1)
(x,y+1) =
(x-1,y-1) (x+1,y-1)
Diagonal neighbors of p:
(x−1,y−1)
p (x+1,y−1)
ND(p) (x−1,y+1)
(x+1,y+1)
(x-1,y+1) (x+1,y+1) =
8-neighbors of p:
(x-1,y-1) (x,y-1) (x+1,y-1)
(x−1,y−1)
(x,y−1)
(x+1,y−1)
(x-1,y) p (x+1,y)
(x−1,y)
N8(p) = (x+1,y)
(x−1,y+1)
(x-1,y+1) (x,y+1) (x+1,y+1)
(x,y+1)
(x+1,y+1)
7
• Some of the points in the N4, ND and N8 may fall
outside image when P lies on the border of image.
Pixel Adjacencies
❑ 3 types of adjacencies
▪ 4-adjacency
▪ 8-adjacency
▪ m-adjacency
11
Pixel Adjacencies
❑ 4-adjacency
– Two pixels p, q are 4-adjacent if
• q is in the set N4(p)
N4(p)
• p, q have values from set V,
(V be the set of intensity values )
p q
r
12
Pixel Adjacencies
❑ 8-adjacency
– Two pixels p, q are 8-adjacent if
• q is in the set N8(p) N8(p)
• p, q have values from set V,
(V be the set of intensity values)
q r
p
13
Pixel Adjacencies
❑ m-adjacency
– Two pixels p, q are m-adjacent if
• p, q have values from set V, and
– q in N4(p), or
– q in ND(p) and
– has no pixel with value from V
q
t
p s
p, q are not m-adjacency pixels
s, t are m-adjacency pixels
14
Connectivity / Digital Path
8-path m-path
p p p
q q q
m-path from p to q
8-path from p to q
solves this ambiguity
results in some ambiguity
16
Adjacency / Connectivity
❑ Let S represent a subset of pixels in an image,
– Two pixels p and q are connected in S if there
is a path between p and q entirely in S
p
S
q
18
Definition of Region
❑ Connected Set, S
– If all pixels of S are connected to p
pp
S
q Region
20
Boundary of a
region
• Boundary of a region, R
– Set of pixels whose at least one neighbor is not in R
– also called border or contour) of a region R
Boundary
or contour
21
Distance Metrics
22
Distance Metrics
23
City block distance (D4
distance)
D4 ( p, q) = x − s + y
−t
⬥ Diamond with center at (x,y)
⬥ D4 = 1 are the 4 neighbors of pixel p(x,y)
24
Chessboard distance (D8
distance)
D8 ( p, q) = max( x − s , y − t
)
⬥ Square centered at p(x,y)
25
Euclidean Distance
(7^2+6^2)^0.
5
= 9.22
29
Class/Home Work
3 1 2 1(a)
• N4(p) =? 2 2 0 2
• N8(p) =?
• Nm(p) =? If V={1,2} 1 2 (p) 1 1
• Is (a) 4-adjacent of (b)? 1(b) 0 1 2
• Is (a) 8-adjacent of (b)?
• Is (a) m-adjacent of (b)?
• Calculate D4 = ?, D8 = ?, De = ? for the point (a) ^ (b).
Text Book 1
Chapter 2: Problems: 2.9 ~ 2.17 excluding 2.14