4-5 Basic Relationship Between Pixels

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 44
At a glance
Powered by AI
The key takeaways are about different types of pixel connectivity and neighborhood relationships, distance measures, and arithmetic/logical operations that can be performed on pixels and images.

The different types of connectivity discussed are 4-connectivity, 8-connectivity, and m-connectivity.

The different distance measures discussed are Euclidean distance, City Block distance, and Chessboard distance.

Basic Relationship between Pixels

Objectives
Different Neighbours Connectivity Region Connectivity pathways Distance Measures Arithmetic/Logical Operations Logical Operations
2

Basic Relationship between Pixels


Terminology:

f(x,y)
S p,q,etc

= image
= subset of pixels f(x,y) = particular
p

f(x,y)

pixels in image
3

4-Neighbours
A pixel p at coordinates (x,y) has 4 horizontal and vertical neighbours, each being a unit distance from (x,y)
y
(x-1,y)
(x,y)

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

x
Note: one or more of these points might lie outside image

Example
0 0 1 2 P1 P4 P7 1 P2 P5 P8 2 P3 P6 P9

N4(P5) = p4,p6 ---- Horizontal Neighbors p2,p8 ---- Vertical Neighbors

N4 (1,1) = (1,0) (1,2) (0,1) (2,1)


5

Diagonal Neighbours ND(p)


A pixel p at coordinates (x,y) has 4 diagonal neighbours, each being a unit distance from (x,y)
Y
(x-1, y-1) (x-1, y+1)
p(x,y)

(x+1, y-1)

(x+1, y-1)

0 0 1 2 P1 P4 P7

1 P2 P5 P8

2 P3 P6 P9

ND(P5) = p1,p3,p9,p7

ND (1,1) = (0,0) (0,2) (2,2) (2,0)


7

8 Neighbours N8(p)
8-neighbours of p= 4 diagonal neighbours of p and 4neighbours of p

N8(p) = ND(p) + N4(p)

p(x,y)

Problems
0 0 P1 P4 P7 1 P2 P5 P8 2 P3 P6 P9

X Y co-ordinate of pixel P2 = (0,1)

1
2

P5 =

P9 =

Problems
N4 (P5)=(L,T,R,B)
P1 P4 P7 P2 P5 P8 P3 P6 P9

= (P4,P2,P6,P8)

ND(P5)=(LT,RT,RB,LB) = (P1,P3,P9,P7) N8(P5) = (L,-----LB) = (P4,P1,P2,P3, P6,P9,P8,P7) = (0,0,P2,P4)

N4 (P1)= (L,T,R,B)

ND(P1)=(LT,RT,RB,LB) = (0,0,P5,0)

10

Connectivity
Connectivity is an important concept for establishing:- boundaries of objects - components of regions in an image Region = set of pixels in which there is a path between any pair of its pixels, all of whose pixels also belong to the set. i.e. adjacent pixels

11

Connectivity
Two pixels are connected if:- they are adjacent (neighbours) - and colour or grey levels are similar
Region 1 Region 2 Region 3 Region 4 Region 5
12

Connectivity - types
V = set of grey-levels used to define intensity = in a grey-scale image, the sub-set of grey values whose intensity value is 31, 32. V(31,32)

3 types of connectivity:- 4-connectivity/ 4-adjacency


8-connectivity

m-connectivity
13

4-Connectivity
Two pixels p and q with values from V are 4connected if q is in the set N4(p)

14

V = (1) p A) q

Problem
p

1 0 0

1 1 0

0 1 1

B)
q

1 0 0

1 1 0

0 1 1

p D) 1 0 0 1 1 0 q 0 1 1 C) 1 0 0

p 1 1 0 0

1 1

Two pixels p and q with values from V are 4connected if q is in the set N4(p)
15

Problems
1 0 1 2 1 3 3 3 4 4 0 4 V1 = (1,2)

(1,2)
1 0 1 2 1 3 3 3 4 4 0 4 (3)

(4)

16

8-Connectivity
Two pixels p and q with values from V are 8connected if q is in the set N8(p)

17

Problems

1
0

2
1

3
3

4
0

18

m-Connectivity
Two pixels p and q with values from V are m-

connected if:1) q is in the set N4(p), or 2) q is in the set ND(P)

and the set N4(p) N4(q) is empty

19

V = (1) p A) 1 q

Problem
p

1 1 0

0 1 1

B)
q

1 0 0

1 1 0

0 1 1

0 0

p D) 1 0 0 1 1 0 q 0 1 1

p C) 1 0 0 0 1 0 0

1 1

q is in the set N4(p), or q is in the set ND(P) and the set N4(p) N4(q) is empty
20

Basic Relationships Between Pixels


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.
21

Connectivity - pathways
A pixel p is adjacent to a pixel q if they are connected.

A path from pixel to pixel q will be a sequence of distinct pixels with their own coordinates.

0 0 0

1 1 0

1 0 1

0 0 0

1 1 0

1 0 1

0 0 0

1 1 0

1 0 1

4 neighbours

8 neighbours

m neighbours
22

Examples: Adjacency and Path


V = {1, 2}

0 1 1 0 2 0 0 0 1
1,1 1,2 2,1 2,2 3,1 3,2

1,3

2,3

3,3

0 1 1 0 2 0 0 0 1
8-adjacent

0 1 1 0 2 0 0 0 1
m-adjacent
The m-path from (1,3) to (3,3):
(1,3), (1,2), (2,2), (3,3)

The 8-path from (1,3) to (3,3):


(i) (1,3), (1,2), (2,2), (3,3) (ii) (1,3), (2,2), (3,3)

23

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.

1 1 1 0

1 1 1 1

1 1 1 0

0 0 0 0

24

Boundary (or border)


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.
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

25

Problem
In the following arrangement of pixels, are the two regions (of 1s) adjacent? (if 8-adjacency is used) 1 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 1

26

In the following arrangement of pixels, are the two parts (of 1s) adjacent? (if 4-adjacency is used) 1 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 1

Part 2

27

In the following arrangement of pixels, the two regions (of 1s) are disjoint (if 4-adjacency is used) 1 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 1

Region 1

Region 2

28

In the following arrangement of pixels, the two regions (of 1s) are disjoint (if 4-adjacency is used) 1 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 1

foreground

background

29

In the following arrangement of pixels, the circled point is part of the boundary of the 1-valued pixels if 8-adjacency is used, true or false? 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0

30

Distance function D
Given pixels p, q and z with coordinates (x, y), (s, t), (u, v) respectively, the distance function D has following properties: D(p, q) 0 [D(p, q) = 0, iff p = q]

a. b. c.

D(p, q) = D(q, p) D(p, z) D(p, q) + D(q, z)

p (i,j) q (h,k)

31

Distance Measures
p (i,j)

q (h,k) Euclidean: City Block: Chessboard: DE(p,q) = [(i-h)2 + (j-k)2]1/2 D4(p,q) = |i-h| + |j-k| D8(p,q) = max{|i-h| , |j-k|}
32

Problems
p (i,j)

q (h,k)
Euclidean: DE(p,q) = [(i-h)2 + (j-k)2]1/2

City Block:
Chessboard:

D4(p,q) = |i-h| + |j-k|


D8(p,q) = max{|i-h| , |j-k|}

If p(I,j) = (2,2) and q(h,k) = (4,4) find Euclidean, City Block, Chessboard distances
33

The following are the different Distance measures:

a. Euclidean Distance : De(p, q) = [(x-s)2 + (y-t)2]1/2


b. City Block Distance: D4(p, q) = |x-s| + |y-t| c. Chess Board Distance: D8(p, q) = max(|x-s|, |y-t|)

34

distance function D
In the following arrangement of pixels, whats the value of the chessboard distance between the circled two points? 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

35

Arithmetic/Logical Operations
Arithmetic and logical operations between pixels are used in most branches of image processing. Arithmetic pixels.

operations

apply

to

multivalued

Logic operations apply only to binary images

36

Arithmetic Operations
For entire images, Arithmetic operations are carried out pixel by pixel.

Addition:
Subtraction: Multiplication:

p + q used for image averaging to reduce noise


p q remove background information p * q used to correct grey level pq shading pxq pq
37

Division:

Logical Operations
Basic tools of binary image processing where they are used for such tasks as masking, feature detection, and shape analysis And: p AND q pq

Or:
Complement:

p OR q p+q
NOT q q

38

Logical Operations - Examples

39

Arithmetic/Logical Operations Footnote


In addition to pixel-by-pixel operations on entire images, arithmetic and logical operations are used in neighbourhood-oriented operations. i.e. mask/filter operations

40

41

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


42

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.

43

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.

44

You might also like