4-5 Basic Relationship Between Pixels
-
Upload
aditya-prakash -
Category
Documents
-
view
613 -
download
2
Transcript of 4-5 Basic Relationship Between Pixels
1
Basic Relationship between Pixels
2
• Different Neighbours• Connectivity• Region• Connectivity – pathways• Distance Measures• Arithmetic/Logical Operations• Logical Operations
Objectives
3
Terminology:
f(x,y) = image
S = subset of pixels f(x,y)
p,q,etc = particular
pixels in image
Basic Relationship between Pixels
p
S
f(x,y)
4
4-Neighbours
A pixel p at coordinates (x,y) has 4 horizontal and vertical neighbours, each being a unit distance from (x,y)
Note: one or more of these points might lie outside image
(x,y)
(x-1,y)
(x+1, y)
(x, y-1)
(x, y+1)
y
x
5
Example
P1 P2 P3
P4 P5 P6
P7 P8 P9
y0 1 2
x
0
1
2
N4(P5) = p4,p6 ---- Horizontal Neighbors
p2,p8 ---- Vertical Neighbors
N4 (1,1) = (1,0) (1,2)
(0,1) (2,1)
6
Diagonal Neighbours ND(p)
• A pixel p at coordinates (x,y) has 4 diagonal neighbours, each being a unit distance from (x,y)
p(x,y)
(x-1, y-1)
(x-1, y+1)
(x+1, y-1)
(x+1, y-1)
Y
x
7
P1 P2 P3
P4 P5 P6
P7 P8 P9
y
ND(P5) = p1,p3,p9,p7
ND (1,1) = (0,0) (0,2)
(2,2) (2,0)
0 1 2
x
0
1
2
8
8 Neighbours N8(p) • 8-neighbours of p= 4 diagonal neighbours of p and 4-
neighbours of p
N8(p) = ND(p) + N4(p) p(x,y)
9
Problems
P1 P2 P3
P4 P5 P6
P7 P8 P9
yX Y co-ordinate of pixel P2 = (0,1)
‘’ ‘’ ‘’ P5 =
‘’ ‘’ P9 =
0 1 2
x
0
1
2
10
Problems
P1 P2 P3
P4 P5 P6
P7 P8 P9
N4 (P5)=(L,T,R,B) = (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)
N4 (P1)= (L,T,R,B) = (0,0,P2,P4)
ND(P1)=(LT,RT,RB,LB) = (0,0,P5,0)
11
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
12
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
13
Connectivity - types
V = set of grey-levels used to define intensity
V(31,32) = in a grey-scale image, the sub-set of
grey values whose intensity value is 31, 32.
3 types of connectivity:- · 4-connectivity/ 4-adjacency
· 8-connectivity
· m-connectivity
14
4-Connectivity
Two pixels p and q with values from V are 4-connected if q is in the set N4(p)
15
Problem
1 1 0
0 1 1
0 0 1
1 1 0
0 1 1
0 0 1
p q
V = (1)
Two pixels p and q with values from V are 4-connected if q is in the set N4(p)
p
q
1 1 0
0 1 1
0 0 1
p
q1 1 0
0 1 1
0 0 1
p
q
A) B)
C)D)
16
Problems
1 2 3 4
0 1 3 0
1 3 4 4
V1 = (1,2)
1 2 3 4
0 1 3 0
1 3 4 4
(1,2)
(3)
(4)
17
8-Connectivity
Two pixels p and q with values from V are 8-connected if q is in the set N8(p)
18
Problems
1 2 3 4
0 1 3 0
1 3 4 4
1 2 3 4
0 1 3 0
1 3 4 4
19
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
20
Problem
1 1 0
0 1 1
0 0 1
1 1 0
0 1 1
0 0 1
p q
V = (1)
p
q
1 0 0
0 1 1
0 0 1
p
q1 1 0
0 1 1
0 0 1
p
q
q is in the set N4(p), or q is in the set ND(P) and the set N4(p) N4(q) is empty
B)
C)D)
A)
21
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 .
22
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 1 1 0 1 1 0 1 1 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1
4 neighbours 8 neighbours m neighbours
23
Examples: Adjacency and Path
01,1 11,2 11,3 0 1 1 0 1 102,1 22,2 02,3 0 2 0 0 2 003,1 03,2 13,3 0 0 1 0 0 1
V = {1, 2}
8-adjacent m-adjacent
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)
The m-path from (1,3) to (3,3):(1,3), (1,2), (2,2), (3,3)
24
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 0 1 1 1 0 0 1 0 0
25
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
26
Problem• In the following arrangement of pixels, are the two regions
(of 1s) adjacent? (if 8-adjacency is used)
1 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1
Region 1
Region 2
27
• In the following arrangement of pixels, are the two parts (of 1s) adjacent? (if 4-adjacency is used)
1 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1
Part 1
Part 2
28
• In the following arrangement of pixels, the two regions (of 1s) are disjoint (if 4-adjacency is used)
1 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1
Region 1
Region 2
29
• In the following arrangement of pixels, the two regions (of 1s) are disjoint (if 4-adjacency is used)
1 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1
foreground
background
30
• 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 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0
31
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:
a. D(p, q) ≥ 0 [D(p, q) = 0, iff p = q]
b. D(p, q) = D(q, p)
c. D(p, z) ≤ D(p, q) + D(q, z)
p (i,j)
q (h,k)
32
Distance Measures
Euclidean: DE(p,q) = [(i-h)2 + (j-k)2]1/2
City Block: D4(p,q) = |i-h| + |j-k|
Chessboard: D8(p,q) = max{|i-h| , |j-k|}
p (i,j)
q (h,k)
33
Problems
Euclidean: DE(p,q) = [(i-h)2 + (j-k)2]1/2
City Block: D4(p,q) = |i-h| + |j-k|
Chessboard: D8(p,q) = max{|i-h| , |j-k|}
p (i,j)
q (h,k)
If p(I,j) = (2,2) and q(h,k) = (4,4) find Euclidean, City Block, Chessboard distances
34
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|)
35
distance function D• In the following arrangement of pixels, what’s the value of the
chessboard distance between the circled two points?
0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
36
Arithmetic/Logical Operations
Arithmetic and logical operations between pixels are used in most branches of image processing.
•Arithmetic operations apply to multivalued pixels.
• Logic operations apply only to binary images
37
Arithmetic OperationsFor entire images, Arithmetic operations are carried out pixel by pixel.
Addition: p + q used for image averaging to reduce noise
Subtraction: p – q remove background information
Multiplication: p * q used to correct grey level pq shadingp x q
Division: p q “ “ “ “··
38
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 qp • q
Or: p OR qp + q
Complement: NOT qq–
39
Logical Operations - Examples
40
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
41
42
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
43
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.
44
• 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.