4-5 Basic Relationship Between Pixels
4-5 Basic Relationship Between Pixels
4-5 Basic Relationship Between Pixels
Objectives
Different Neighbours Connectivity Region Connectivity pathways Distance Measures Arithmetic/Logical Operations Logical Operations
2
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
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
(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
8 Neighbours N8(p)
8-neighbours of p= 4 diagonal neighbours of p and 4neighbours of p
p(x,y)
Problems
0 0 P1 P4 P7 1 P2 P5 P8 2 P3 P6 P9
1
2
P5 =
P9 =
Problems
N4 (P5)=(L,T,R,B)
P1 P4 P7 P2 P5 P8 P3 P6 P9
= (P4,P2,P6,P8)
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)
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-
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
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
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)
23
1 1 1 0
1 1 1 1
1 1 1 0
0 0 0 0
24
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.
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:
If p(I,j) = (2,2) and q(h,k) = (4,4) find Euclidean, City Block, Chessboard distances
33
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
36
Arithmetic Operations
For entire images, Arithmetic operations are carried out pixel by pixel.
Addition:
Subtraction: Multiplication:
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
39
40
41
For every pixel p in S, the set of pixels in S that are connected to p is called a connected component of S.
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