03 - Chapter 1 - CV - Introduction - Some Basic Relationships Between Pixels
03 - Chapter 1 - CV - Introduction - Some Basic Relationships Between Pixels
Introduction to
whose values are from V We can define type of adjacency: 4-adjacency, 8-adjacency
or m-adjacency depending on type of connectivity.
1. 4-adjacency: Two pixels p and q with values In this example, we can note that to connect between
Computer Vision and Image Processing, [email protected]. 2024
0 1 1 0 1 1 0 1 1
0 1,1 1 1,2 1 1,3 0 1 1 0 1 1
0 2 0 0 2 0 0 2 0
0 2,1 2 2,2 0 2,3 0 2 0 0 2 0
0 0 1 0 0 1 0 0 1
0 3,1 0 3,2 1 3,3 0 0 1 0 0 1
0 1 1 0 1 1 0 1 1 m-adjacent
8-adjacent
0 2 0 0 2 0 0 2 0
The 8-path from (1,3) to (3,3): The m-path from (1,3) to (3,3):
0 0 1 0 0 1 0 0 1 (i) (1,3), (1,2), (2,2), (3,3) (1,3), (1,2), (2,2), (3,3)
m-adjacent (ii) (1,3), (2,2), (3,3)
8-adjacent
Some basic relationships Some basic relationships
between pixels between pixels
Region
Computer Vision and Image Processing, [email protected]. 2024
Boundary Boundary
Computer Vision and Image Processing, [email protected]. 2024
1 1 1 1 1 1 1 1 1
Region 1 Part 1 Region 1
1 0 1 1 0 1 1 0 1
0 1 0 0 1 0 0 1 0
0 0 1 Region 2 0 0 1 Part 2 Region 2
0 0 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
Some basic relationships Some basic relationships
between pixels between pixels
p 2 1 1 4 p 2 1 1 4 5 4p 2 3 3 6 5 4p 2 3 3 6
Where: x p
A. D (p,q) ≥ 0, D(p,q) = 0 iff p = q
x=x1 , y=y1
B. D(p,q) = D(q,p) s=x2 , t=y2
C. D(p,z) ≤ D(p,q) + D(q,z) s q
Euclidean Distance
Some basic relationships Some basic relationships
between pixels between pixels
Distance Measures y t Distance Measures y t
Computer Vision and Image Processing, [email protected]. 2024
,
In this case, the pixels having a D8
City Block Distance distance from (x,y) less than or equal to Chessboard Distance
some value r from a square centered at
Example
(x,y).
The pixels with D4 distance ≤ from (x, y) (the center point)
Example
from the following contours of constant distance:
The pixels with D8 distance ≤ from (x,y) (the
center point) from the following contours of
The pixels with D4 =1 are the 4-nieghbors of (x, y).
constant distance
The pixels with D8 =1 are the 8-nieghbors of (x, y).
,
pixels. and q are two pixels.
0 0 0 1
,
apart.
Image Distance transform
, ,
or corners touch are 1 unit apart. 0 0 0 1 1 1
, , ,
2 1 1 1 2
2 1 0 1 2
2 1 0 1 2
2 1 2
2 1 1 1 2
2
2 2 2 2 2
The pixels with D4 = 1 are the 4-neighbors of (x,y)
D8 = 1 are the 8-neighbors of (x,y)
= (Sum of all the rows positions 1 1 1 0 0 0 0 0 o When 8-connectivity is used to determine whether a pixel
in the region) / A 1 1 1 0 2 2 0 0 inside the region is connected to a pixel outside the
1 1 1 0 2 2 0 0 region, the resulting set of perimeter pixel is 4-connected.
length of the perimeter squared divided by the area.
in P must be ordered in a sequence:
P = <(r0,c0),. . . , (rk-1,ck-1)>, It is the measurement of compactness of object.
Circularity 2:
colums are
, ,
indexed
from 0
"#
Where the set of pixels , , k=0,…,K-1 lie on the Properties of the three
perimeter P of the region. The circularity measure C2 increases regions
rigion rigion row of col of perim. circu- circu- radius radius
monotonically as the digital shape becomes more circular and is num area center center lenght larity1 larity2 mean Var.
similar for digital and continuous shapes 1 44 6 11.5 21.2 10.2 15.4 3.33 0.05
2 48 9 1.5 28 16.3 2.5 3.80 2.28
3 9 13 7 8 7.1 5.8 1.20 0.04
/0(, ,) ∈
*(, ,) .
# /0(, ,) ∉
A A B
B
C D
C
D
Image Representation & Image Representation &
Description Description
Run length code & QuadTree Code Chain Codes & Shape Numbers
QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024
4-directional 8-directional
chain code chain code
• The chain code of a boundary depends on the boundary depends on the starting point.
starting point.
• Normalize the chain code by using the first
• The shape number of a chain coded
difference of the chain code. boundary is defined as the first difference of
• Example: the chain code is 10103322, the first smallest magnitude.
difference is 3133030 or 33133030, the 1st “3” is • The difference of a chain code is
obtained by connecting the last and the first element independent of its rotation, it depend on the
of the chain. orientation of the grid.
• Size normalization can be • The order n of a shape number is defined as
obtained by alternating the
size of the sampling grid. the number of digits in its representation.
Image Representation & Image Representation &
Description Description
Chain Codes & Shape Numbers: Example
Chain Codes & Shape Numbers Chain code: 0 3 0 3 2 2 1 1
Computer Vision and Image Processing, [email protected]. 2024
Computer Vision and Image Processing, [email protected]. 2024 boundary depends on the orientation of the grid.
Normalization:
• Major axis: the line through the centroid of the boundary
pixels and parallel to the direction of maximum variance of
the boundary pixels.
• Minor axis: the line through the centroid of the boundary
pixels and perpendicular to the direction of maximum
variance of the boundary pixels.
Image Representation & Image Representation &
Description Description
Chain Codes & Shape Numbers: Example Chain Codes & Shape Numbers: Example
When
Computer Vision and Image Processing, [email protected]. 2024
boundary pixel coordinates, the angle θ that the of order n of which the eccentricity is the closest to
')) 89)
major axis makes with the horizontal is given by that of the basic rectangle. This determines the size
3 4%'546 4%'546 )
'77 8:
of the grid cells
2x4: eccentricity 2
For example, options for n=12:;3x3: eccentricity 1
Construct a basic rectangle in such a way that the
1x5: eccentricity 5
boundary fits within it
length of major axis
Eccentricity of boundary =
length of minor axis
2. Find the major and minor axis 1. Original boundary Circular chain code:
0000300322322212110
3. Find the closest rectangle of order 18 is 3x6
First difference mod 4:
4. Obtain chain code 000310330130031303
Translation ∆ * * ∆ M *
Scaling N * N *
Starting point
# * * !J O # */
Image Representation & Image Representation &
Description Description
Statistical Moments Regional Descriptors
Definition: the nth moment Purpose: to describe regions or “areas”
Example of moment:
Computer Vision and Image Processing, [email protected]. 2024
E = -2
R0
S ( ) Sr ( )
r 1
Another Another
image S(q)
S ( r ) S ( r )
Sum all pixels in each area 0
∅
17.180 16.954 19.955 17.270 16.803
∅
22.655 23.531 26.689 22.836 19.724
∅R
22.919 24.236 26.901 23.130 20.437
∅S
45.749 48.349 53.724 46.136 40.525
∅T
31.830 32.916 37.134 32.068 29.315
45.589 48.343 53.590 46.017 40.470
Invariant Moments of
4. Rotated 2 degree 5. Rotated 45 degree
Two-D Functions:
Example
Invariant moments are
independent of rotation,
translation, scaling, and reflection
K
x x
k 1
k
T
k m x mTx component of y with the largest l is called the principal
component.
Image Representation & Image Representation &
Description Description
Use of Principal Components for Description Principal Components: Examples
6 spectral images
Computer Vision and Image Processing, [email protected]. 2024
Component
1 3210
2 931.4
3 118.5
4 83.88
5 64.00
6 13.40
Steps in building
a structure.
A simple composite region
[email protected]
Company
LOGO
Some basic relationships between
(COMPUTER VISION) pixels
Introduction to
whose values are from V We can define type of adjacency: 4-adjacency, 8-adjacency
or m-adjacency depending on type of connectivity.
1. 4-adjacency: Two pixels p and q with values In this example, we can note that to connect between
Computer Vision and Image Processing, [email protected]. 2024
0 1 1 0 1 1 0 1 1
0 1,1 1 1,2 1 1,3 0 1 1 0 1 1
0 2 0 0 2 0 0 2 0
0 2,1 2 2,2 0 2,3 0 2 0 0 2 0
0 0 1 0 0 1 0 0 1
0 3,1 0 3,2 1 3,3 0 0 1 0 0 1
0 1 1 0 1 1 0 1 1 m-adjacent
8-adjacent
0 2 0 0 2 0 0 2 0
The 8-path from (1,3) to (3,3): The m-path from (1,3) to (3,3):
0 0 1 0 0 1 0 0 1 (i) (1,3), (1,2), (2,2), (3,3) (1,3), (1,2), (2,2), (3,3)
m-adjacent (ii) (1,3), (2,2), (3,3)
8-adjacent
Some basic relationships Some basic relationships
between pixels between pixels
Region
Computer Vision and Image Processing, [email protected]. 2024
Boundary Boundary
Computer Vision and Image Processing, [email protected]. 2024
1 1 1 1 1 1 1 1 1
Region 1 Part 1 Region 1
1 0 1 1 0 1 1 0 1
0 1 0 0 1 0 0 1 0
0 0 1 Region 2 0 0 1 Part 2 Region 2
0 0 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
Some basic relationships Some basic relationships
between pixels between pixels
p 2 1 1 4 p 2 1 1 4 5 4p 2 3 3 6 5 4p 2 3 3 6
Where: x p
A. D (p,q) ≥ 0, D(p,q) = 0 iff p = q
x=x1 , y=y1
B. D(p,q) = D(q,p) s=x2 , t=y2
C. D(p,z) ≤ D(p,q) + D(q,z) s q
Euclidean Distance
Some basic relationships Some basic relationships
between pixels between pixels
Distance Measures y t Distance Measures y t
Computer Vision and Image Processing, [email protected]. 2024
,
In this case, the pixels having a D8
City Block Distance distance from (x,y) less than or equal to Chessboard Distance
some value r from a square centered at
Example
(x,y).
The pixels with D4 distance ≤ from (x, y) (the center point)
Example
from the following contours of constant distance:
The pixels with D8 distance ≤ from (x,y) (the
center point) from the following contours of
The pixels with D4 =1 are the 4-nieghbors of (x, y).
constant distance
The pixels with D8 =1 are the 8-nieghbors of (x, y).
,
pixels. and q are two pixels.
0 0 0 1
,
apart.
Image Distance transform
, ,
or corners touch are 1 unit apart. 0 0 0 1 1 1
, , ,
2 1 1 1 2
2 1 0 1 2
2 1 0 1 2
2 1 2
2 1 1 1 2
2
2 2 2 2 2
The pixels with D4 = 1 are the 4-neighbors of (x,y)
D8 = 1 are the 8-neighbors of (x,y)
= (Sum of all the rows positions 1 1 1 0 0 0 0 0 o When 8-connectivity is used to determine whether a pixel
in the region) / A 1 1 1 0 2 2 0 0 inside the region is connected to a pixel outside the
1 1 1 0 2 2 0 0 region, the resulting set of perimeter pixel is 4-connected.
length of the perimeter squared divided by the area.
in P must be ordered in a sequence:
P = <(r0,c0),. . . , (rk-1,ck-1)>, It is the measurement of compactness of object.
Circularity 2:
colums are
, ,
indexed
from 0
"#
Where the set of pixels , , k=0,…,K-1 lie on the Properties of the three
perimeter P of the region. The circularity measure C2 increases regions
rigion rigion row of col of perim. circu- circu- radius radius
monotonically as the digital shape becomes more circular and is num area center center lenght larity1 larity2 mean Var.
similar for digital and continuous shapes 1 44 6 11.5 21.2 10.2 15.4 3.33 0.05
2 48 9 1.5 28 16.3 2.5 3.80 2.28
3 9 13 7 8 7.1 5.8 1.20 0.04
/0(, ,) ∈
*(, ,) .
# /0(, ,) ∉
A A B
B
C D
C
D
Image Representation & Image Representation &
Description Description
Run length code & QuadTree Code Chain Codes & Shape Numbers
QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024
4-directional 8-directional
chain code chain code
• The chain code of a boundary depends on the boundary depends on the starting point.
starting point.
• Normalize the chain code by using the first
• The shape number of a chain coded
difference of the chain code. boundary is defined as the first difference of
• Example: the chain code is 10103322, the first smallest magnitude.
difference is 3133030 or 33133030, the 1st “3” is • The difference of a chain code is
obtained by connecting the last and the first element independent of its rotation, it depend on the
of the chain. orientation of the grid.
• Size normalization can be • The order n of a shape number is defined as
obtained by alternating the
size of the sampling grid. the number of digits in its representation.
Image Representation & Image Representation &
Description Description
Chain Codes & Shape Numbers: Example
Chain Codes & Shape Numbers Chain code: 0 3 0 3 2 2 1 1
Computer Vision and Image Processing, [email protected]. 2024
Computer Vision and Image Processing, [email protected]. 2024 boundary depends on the orientation of the grid.
Normalization:
• Major axis: the line through the centroid of the boundary
pixels and parallel to the direction of maximum variance of
the boundary pixels.
• Minor axis: the line through the centroid of the boundary
pixels and perpendicular to the direction of maximum
variance of the boundary pixels.
Image Representation & Image Representation &
Description Description
Chain Codes & Shape Numbers: Example Chain Codes & Shape Numbers: Example
When
Computer Vision and Image Processing, [email protected]. 2024
boundary pixel coordinates, the angle θ that the of order n of which the eccentricity is the closest to
major axis makes with the horizontal is given by that of the basic rectangle. This determines the size
3 = , = ,
of the grid cells
2x4: eccentricity = 2
Construct a basic rectangle in such a way that the For example, options for n=12:43x3: eccentricity = 1
boundary fits within it 1x5: eccentricity = 5
length of major axis
Eccentricity of boundary =
length of minor axis
2. Find the major and minor axis 1. Original boundary Circular chain code:
0000300322322212110
3. Find the closest rectangle of order 18 is 3x6
First difference mod 4:
4. Obtain chain code 000310330130031303
Translation = + ∆ * = * + ∆ E *
Scaling =F * = F *
Starting point
= − # * = * !C G # */
Image Representation & Image Representation &
Description Description
Statistical Moments Regional Descriptors
Definition: the nth moment Purpose: to describe regions or “areas”
Example of moment:
Computer Vision and Image Processing, [email protected]. 2024
E = -2
R0
S ( ) Sr ( )
r 1
Another Another
image S(q)
S ( r ) S ( r )
Sum all pixels in each area 0
∅
17.180 16.954 19.955 17.270 16.803
∅
22.655 23.531 26.689 22.836 19.724
∅J
22.919 24.236 26.901 23.130 20.437
∅K
45.749 48.349 53.724 46.136 40.525
∅L
31.830 32.916 37.134 32.068 29.315
45.589 48.343 53.590 46.017 40.470
Invariant Moments of
4. Rotated 2 degree 5. Rotated 45 degree
Two-D Functions:
Example
Invariant moments are
independent of rotation,
translation, scaling, and reflection
K
x x
k 1
k
T
k m x mTx component of y with the largest l is called the principal
component.
Image Representation & Image Representation &
Description Description
Use of Principal Components for Description Principal Components: Examples
6 spectral images
Computer Vision and Image Processing, [email protected]. 2024
Component
1 3210
2 931.4
3 118.5
4 83.88
5 64.00
6 13.40
Steps in building
a structure.
A simple composite region
[email protected]
Company
LOGO