Neighbors of pixel, Adjacency, connectivity, path
Neighbors of a pixel
A pixel p at coordinates (x,y) has four horizontal and vertical
neighbors.
4-neighbors of p, denoted by N4(p):
(x-1, y), (x+1, y), (x,y-1), and (x, y+1).
Neighbors of a pixel ( 8 neighbor)
4 diagonal neighbors of p, denoted by ND(p):
(x-1, y-1), (x+1, y+1), (x+1,y-1), and (x-1, y+1).
8 neighbors of p, denoted N8(p)
N8(p) = N4(p) U ND(p)
Adjacency
Let V be the set of intensity values to define adjacency.
In a binary image, V={1} if we are referring to adjacency
of pixels value 1.
In gray-scale image, the idea is same but set V typicaly
contains more elements.
In the adjacency of pixels with a range of possible
intensity values 0 to 255, set V could be any subset of
these 256 values.
Adjacency
4-adjacency: Two pixels p and q with values from
V are 4-adjacent if q is in the set N4(p).
8-adjacency: Two pixels p and q with values from
V are 8-adjacent if q is in the set N8(p).
0 1 1 0 1 1
0 1 0 0 1 0
0 0 1 0 0 1
a. 4 adjacency b. 8- adjacency
Adjacency
m-adjacency: Two pixels p and q with values from
V are m-adjacent if
(i) q is in the set N4(p), or
(ii) q is in the set ND(p) and the set N4(p) ∩ N4(q) has no
pixels whose values are from V.
Adjacency(m-adjacency)
Not m-connected.
0 1 1
They have a common
4- connected
0 1 0
neighbor.
0 0 1
m-connected. They do not have
any common 4-connected neighbor
Path
A (digital) path (or curve) from a pixel p with
coordinate(x, y) to pixel q with coordinate (s, t) is a
sequence of distinct pixels with coordinates
(x0, y0), (x1, y1), (x2, y2),…,(xn, yn)
(x0, y0)=(x, y) and (xn, yn)=(s, t)
pixel (xi, yi) and (xi-1, yi-1) are adjacent for 1≤ i≤n.
n is the length of the path.
If (x0, y0)= (xn, yn) then the path is closed path.
4-, 8-, m- paths are defined depending on the type of
adjacency specified.
Path(example)
Connectivity
Let S represent a subset of pixels in an image.
Two pixels p and q are said to be connected in S if
there exists a path between them consisting entirely of
pixels in S.
For any pixel p in S, the set of pixels that are connected
to it in S is called connected component of S.
If it only has one component connected, then S is
called a connected set.
Connectivity(example)
1 1 1 r1 1 0 0
1 1 1 r1 1 0 0
0 1 0 0 0 0
0 1 1 0 0 1
1 1 1 r2 1 1 1 r2
1 1 1 1 1 1
a. r1 and r2 region are connected
b. r1 and r2 region are not connected.
if 4- adjacency is used.
connectivity
1 1 1
r1
1 0 1
0 1 0 If we consider 8/m adjacency
it is connected component
0 0 1
1 1 1 r2
1 1 1
If we consider 4 adjacency it is not connected component