You are on page 1of 6

Basic Relationship of Pixels

Digital Image Processing


(0,0) x

(x-1,y-1) (x,y-1) (x+1,y-1)


Basic Relations between Pixels
(x-1,y) (x,y) (x+1,y)
y

(x-1,y+1) (x,y+1) (x+1,y+1)

Conventional indexing method

Neighbors of a Pixel Neighbors of a Pixel (cont.)

Neighborhood relation is used to tell adjacent pixels. It is


useful for analyzing regions.
(x-1,y-1) (x+1,y-1) Diagonal neighbors of p:
(x,y-1) 4-neighbors of p:
p
(x-1,y-1)
(x+1,y-1)
(x-1,y) p (x+1,y)
(x-1,y) ND(p) = (x-1,y+1)
(x+1,y) (x-1,y+1) (x+1,y+1)
N4(p) = (x+1,y+1)
(x,y-1)
(x,y+1)
(x,y+1)

Diagonal -neighborhood relation considers only diagonal


4-neighborhood relation considers only vertical and neighbor pixels.
horizontal neighbors.
Note: q N4(p) implies p N4(q)

1
Neighbors of a Pixel (cont.)
Basic Relations between Pixels
 Neighbors of a pixel
(x-1,y-1) (x,y-1) (x+1,y-1) 8-neighbors of p:  Horizontal and vertical neighbors.
 (x+1, y), (x-1, y), (x, y+1), (x, y-1)
(x-1,y) p (x+1,y)
(x-1,y-1)  Four diagonal neighbors: ND(p)
(x,y-1)  (x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1, y-1)
(x+1,y-1)  4-neighbors of p = N4(p).
(x-1,y+1) (x,y+1) (x+1,y+1)
(x-1,y)  8-neighbors of p = N8(p).
N8(p) = (x+1,y)  N8(p) = N4(p) ∪ ND(p)
(x-1,y+1)  Each neighbor is at a unit distance from point p
The points ND(P) and N4(P) are
 If p is a boundary pixel then it will have less no. of neighbors
together known as 8-neighbors of the (x,y+1)
point P, denoted by N8(P).
(x+1,y+1)
 Connectivity
8-neighborhood relation considers all neighbor pixels.  Adjacency

Connectivity

Example
Connectivity is adapted from neighborhood relation.
Two pixels are connected if they are in the same class (i.e. the
same color or the same range of intensity) and they are
neighbors of one another.

For p and q from the same class


w 4-connectivity: p and q are 4-connected if q N4(p) 8- neighbour of m- neighbour
the center pixel of the center
w 8-connectivity: p and q are 8-connected if q N8(p) pixel

w mixed-connectivity (m-connectivity):
p and q are m-connected if q N4(p) or • m-connectivity eliminates the multiple path connections that
q ND(p) and N4(p) N4(q) =  arise in 8-connectivity.

2
• 4-adjacency: if q is in the set N4(p).
Adjacency • 8-adjacency: if q is in the set N8(p).
 A pixel p is adjacent to a pixel q if they are connected. • m-adjacency: if
– if q is in the set N4(p), or
– if q is in the set ND(p) and the set N4(p)∩N4(q) has no
pixels whose values are from V.
• Mixed adjacency is a modification of 8-adjacency and is
p p used to eliminate the multiple path connections that often
arise when 8-adjacency is used.

8-adjacency:
4-adjacency: N4(p) ∪N (p)
D
N4(p)
We can define type of adjacency: 4-adjacency, 8-adjacency
or m-adjacency depending on type of connectivity.

Adjacency
m-Adjacency
 A mixed adjacency combines 4- and 8-adjacency to avoid A pixel p is adjacent to pixel q is they are connected.
the ambiguities. Two image subsets S1 and S2 are adjacent if some pixel
in S1 is adjacent to some pixel in S2

Multiple 8-adjacency m-adjacency


S1
Two pixels p and q are m-adjacent if S2
(i) q is in N4(p) or,
(ii)q is in ND(p) and N4(p)∩ N4(q) has no pixel.

3
Path Path (cont.)

A path from pixel p at (x,y) to pixel q at (s,t) is a sequence


of distinct pixels:
(x0,y0), (x1,y1), (x2,y2),…, (xn,yn) 8-path m-path
such that
p p p
(x0,y0) = (x,y) and (xn,yn) = (s,t)
and
(xi,yi) is adjacent to (xi-1,yi-1), for i = 1,…,n
q q q
q
p
8-path from p to q m-path from p to q
results in some ambiguity solves this ambiguity
We can define type of path: 4-path, 8-path or m-path
depending on type of adjacency.

 Distance measures  for pixel p, q and z with coordinates (x,y), (s,t) and
2
 Euclidean distance 2 1 2
(u,v) respectively,
 City-block distance or D4 distance. 2 1 0 1 2  Any function D holding the following three condition is a
D4(p, q)= |x - s | + |y - t | 2 1 2 'distance' (or a metric)
 D8 distance or chessboard distance. 2  D is a distance function or metric if
D8(p, q)= max (|x - s |, | y - t |)  (a) D(p,q) ≥ 0 ; D(p,q) = 0 iff p=q
2 2 2 2 2  (b) D(p,q) = D(q,p)
2 1 1 1 2
 (c) D(p,z) ≤ D(p,q) + D(q,z)
2 1 0 1 2
2 1 1 1 2
2 2 2 2 2

4
Euclidean distance
between p and q
 The distance between points with co-ordinates (x, y) and
(s, t) may be defined in several different ways. Here, we
discuss the following distance metrics:
 the Euclidean distance,
 the 'city block' distance, and
 the 'chessboard' distance.

City-block distance:
D4 distance
 The distance between two points can also be expressed
as the minimum number of elementary steps in the digital
grid which are needed to move from the starting point to
the end point. If only horizontal and vertical moves are
allowed, the distance D4 is obtained.

 The distance D4 is also called 'city block' distance


because of the analogy with the distance between two
locations in a city with a rectangular grid of streets and
closed blocks of houses:

5
Chessboard distance: D8 distance
 If moves in diagonal directions are allowed in the
digitization grid, we obtain the distance D8, often called
the 'chessboard' distance.
 The distance D8 is equal to the number of minimal king-
moves on the chessboard from one part to another:

You might also like