Вы находитесь на странице: 1из 8

Digital Image Processing

Lecture - 3

Subject Code : EI802C(EC)


Applied Electronics & Instrumentation
Dr. B. C. Roy Engineering College, Durgapur
Prepared by: Anirban Bose
Relationships between pixels
Neighbours of a Pixel
 A pixel p at coordinates (x,y) has four horizontal and
vertical neighbors whose coordinates are given by:
(x+1,y), (x-1, y), (x, y+1), (x,y-1)

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

 This set of pixels, called the 4-neighbors or p, is denoted by


N4(p).
 If one of the neighbours lies outside the digital image then
p is on the border of the image.
2
 The four diagonal neighbors of p have coordinates:
(x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1, y-1)

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


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

and are denoted by ND (p).


 These points, together with the 4-neighbors, are called
the 8-neighbors of p, denoted by N8 (p).

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


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

 As before, if some of the points in ND (p) and N8 (p) fall


outside the image then p(x,y) is on the border of the image.

3
Adjacency and Connectivity
 Let V: a set of intensity values used to define adjacency and
connectivity.
 In a binary/black & white image, V = {1}, if we are referring to
adjacency of pixels with value 1.
 In a gray-scale image, the idea is the same, but V typically contains
more elements, for example, V = {0, 18, 182, …, 200}
 If the possible intensity values are 0 – 255, {V} set can be any
subset of these 256 values.
Types of 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).
 m (mixed)-adjacency: Two pixels p and q with values from V are
m-adjacent if :
• q is in N4(p) or
• q is in ND(p) and the set N4(p) ∩ N4(q) has no pixel whose
4
values are from V (no intersection)
Lets try an example…
0 1 1 2 3
(0,0) (0,1) (0,2) (0,3) (0,4)  N4 (p) = {(3,2), (2,3), (3,4), (4,3)}
1 1 2 0 1
(1,0) (1,1) (1,2) (1,3) (1,4)  ND (p) = {(2,2), (2,4), (4,2), (4,4)}
2 2 3 3 2
(2,0) (2,1) (2,2) (2,3) (2,4)  N8 (p) = {(2,2), (2,3), (2,4), (3,2),
1 3 0 0 1 (3,4), (4,2), (4,3), (4,4)}
(3,0) (3,1) (3,2) (3,3) (3,4)
0 0 2 0 1 A4 (p,q1) = YES; A8 (p,q1) = YES;
(4,0) (4,1) (4,2) (4,3) (4,4) Am(p,q1) = YES

p(4,4) = 0, q1 (3,4) = 3, A4 (p,q2) = NO; A8 (p,q2) = YES;


q2 (3,5) = 2, q3 (4,5) = 1 Am(p,q2) = NO

V = {0, 2, 3} Adjacency Can’t Be Calculated

5
A Digital Path
 A digital path (or curve) from 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), …, (xn, yn) where (x0,y0) = (x,y) and (xn, yn) = (s,t) and pixels
(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), the path is closed.
 We can specify 4-, 8- or m-paths depending on the type of adjacency
specified.
V = {0, 2, 3} 0 1 1 2 3

1 1 2 0 1

2 2 3 3 2

1 3 0 0 1

0 0 2 0 1

6
Distance Measures
 For pixels p, q and z, with coordinates (x,y), (s,t) and (v,w),
respectively, D is a distance function if:
(a) D (p,q) ≥ 0 (D (p,q) = 0 iff p = q), D44 ≤
D ≤22 and D88 ≤
and D ≤22
(b) D (p,q) = D (q, p), and 2
(c) D (p,z) ≤ D (p,q) + D (q,z).
2 1 2

o The Euclidean Distance between p and q is 2 1 0 1 2


defined as: De (p,q) = [(x – s)2 + (y - t)2]1/2 2 1 2
2
o The D4 distance (also called city-block
distance) between p and q is defined as: 2 2 2 2 2
D4 (p,q) = | x – s | + | y – t | 2 1 1 1 2
o The D8 distance (also called chessboard
2 1 0 1 2
distance) between p and q is defined as:
D8 (p,q) = max(| x – s |,| y – t |) 2 1 1 1 2
2 2 2 2 2
7
Enough
Maths for One Day

We will meet again….

Вам также может понравиться