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

Pixel Relationship

Basic Relationship of Pixels

(0,0) x

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

(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
Neighborhood relation is used to tell adjacent pixels. It is
useful for analyzing regions.

(x,y-1) 4-neighbors of p:

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

4-neighborhood relation considers only vertical and


horizontal neighbors.
Note: q N4(p) implies p N4(q)
Neighbors of a Pixel (cont.)

(x-1,y-1) (x+1,y-1) Diagonal neighbors of p:

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

Diagonal -neighborhood relation considers only diagonal


neighbor pixels.
Neighbors of a Pixel (cont.)

(x-1,y-1) (x,y-1) (x+1,y-1) 8-neighbors of p:

(x-1,y) p (x+1,y)
(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)
N8(p) = (x+1,y)
(x-1,y+1)
(x,y+1)
(x+1,y+1)
> 8-neighborhood relation considers all neighbor pixels.
Some of the points in ND(p) and N8(p) fall outside the image if (x,y) is
on the border of the image
Connectivity
Connectivity is adapted from neighborhood relation.
Two pixels are connected if they are neighbors of one another
and if they are in the same class (i.e. the same color or the same
range of intensity or if the gray levels are equal)

For p and q from the same class

w 4-connectivity: p and q are 4-connected if q N4(p)


w 8-connectivity: p and q are 8-connected if q N8(p)
w mixed-connectivity (m-connectivity):
p and q are m-connected if q N4(p) or
q ND(p) and N4(p) N4(q) = 
Adjacency
A pixel p is adjacent to pixel q is they are connected.
Two image subsets S1 and S2 are adjacent if some pixel
in S1 is adjacent to some pixel in S2

S1
S2
We can define type of adjacency: 4-adjacency, 8-adjacency
or m-adjacency depending on type of connectivity.
Path
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)
such that
(x0,y0) = (x,y) and (xn,yn) = (s,t)
and
(xi,yi) is adjacent to (xi-1,yi-1), i = 1,…,n

q
p

We can define type of path: 4-path, 8-path or m-path


depending on type of adjacency.
PATH

 A (digital) path (or curve) from pixel p with coordinates (x0, y0) to pixel q
with coordinates (xn, yn) is a sequence of distinct pixels with coordinates

(x0, y0), (x1, y1), …, (xn, yn)

Where (xi, yi) and (xi-1, yi-1) are adjacent for 1 ≤ i ≤ n.

 Here n is the length of the path.

 If (x0, y0) = (xn, yn), the path is closed path.

 We can define 4-, 8-, and m-paths based on the type of adjacency used.
Examples: Adjacency and Path
V = {1, 2}

0 1 1 0 1 1 0 1 1
0 2 0 0 2 0 0 2 0
0 0 1 0 0 1 0 0 1
Examples: Adjacency and Path
V = {1, 2}

0 1 1
1,1 1,2 1,3 0 1 1 0 1 1
0 2 0
2,1 2,2 2,3 0 2 0 0 2 0
0 0 1
3,1 3,2 3,3 0 0 1 0 0 1
8-adjacent m-adjacent

The 8-path from (1,3) to (3,3): The m-path from (1,3) to (3,3):
(i) (1,3), (1,2), (2,2), (3,3) (1,3), (1,2), (2,2), (3,3)
(ii) (1,3), (2,2), (3,3)
Path (cont.)

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
Connected set

Let S represent a subset of pixels in an image

• For every pixel p in S, the set of pixels in S that are connected to p is


called a connected component of S.

• If S has only one connected component, then S is called Connected


Set.

• We call R a region of the image if R is a connected set

• Two regions, Ri and Rj are said to be adjacent if their union forms a


connected set.
• Regions that are not to be adjacent are said to be disjoint.
• Boundary (or border)

 The boundary of the region R is the set of pixels in the region that
have one or more neighbors that are not in R.
 If R happens to be an entire image, then its boundary is defined as the
set of pixels in the first and last rows and columns of the image.

• Foreground and background

 An image contains K disjoint regions, Rk, k = 1, 2, …, K. Let Ru denote


the union of all the K regions, and let (Ru)c denote its complement.
All the points in Ru is called foreground;
All the points in (Ru)c is called background.
Distance
For pixel p, q, and z with coordinates (x,y), (s,t) and (u,v),
D is a distance function or metric if

w D(p,q) 0 (D(p,q) = 0 if and only if p = q)

w D(p,q) = D(q,p)

w D(p,z) D(p,q) + D(q,z)

Example: Euclidean distance

De ( p, q)  ( x - s )2 + ( y - t ) 2
Distance (cont.)

D4-distance (city-block distance) is defined as

D4 ( p, q)  x - s + y - t

2
2 1 2
2 1 0 1 2
2 1 2
2

Pixels with D4(p) = 1 is 4-neighbors of p.


Distance (cont.)

D8-distance (chessboard distance) is defined as

D8 ( p, q)  max( x - s , y - t )

2 2 2 2 2
2 1 1 1 2
2 1 0 1 2
2 1 1 1 2
2 2 2 2 2

Pixels with D8(p) = 1 is 8-neighbors of p.

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