0% found this document useful (0 votes)
5 views62 pages

03 - Chapter 1 - CV - Introduction - Some Basic Relationships Between Pixels

This document provides an introduction to basic relationships between pixels in computer vision, focusing on concepts such as pixel adjacency, connectivity, regions, boundaries, and digital paths. It explains different types of adjacency (4-adjacency, 8-adjacency, and m-adjacency) and their implications for image processing. Additionally, it discusses the definitions of foreground and background in relation to image regions and outlines the concept of digital paths between pixels.

Uploaded by

tranduytran892
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views62 pages

03 - Chapter 1 - CV - Introduction - Some Basic Relationships Between Pixels

This document provides an introduction to basic relationships between pixels in computer vision, focusing on concepts such as pixel adjacency, connectivity, regions, boundaries, and digital paths. It explains different types of adjacency (4-adjacency, 8-adjacency, and m-adjacency) and their implications for image processing. Additionally, it discusses the definitions of foreground and background in relation to image regions and outlines the concept of digital paths between pixels.

Uploaded by

tranduytran892
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Some basic relationships between

(COMPUTER VISION) pixels

Introduction to

Computer Vision and Image Processing, [email protected]. 2024


1 Neighbors of a pixel, Adjacency and
Chapter 1: Connectivity
Computer vision 2 Regions, Boundaries, Edge

Some basic relationships between pixels 3 Foreground and background

ThS: TRẦN VĂN HÙNG 4 Digital path


Email: [email protected]
E-Learning: Trần Văn Hùng 5 Distance Measures
ocw.fet.iuh.edu.vn
Company
6 Image Representation & Description
LOGO
Company Logo

Some basic relationships between


pixels Basic Relationship of Pixels

Neighbors of a pixel (0,0) x


Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


• Some of the points in ND(p), N4(p) and N8(p) fall outside the
image if (x,y) is on the border of the image.
(x-1,y-1) (x-1,y) (x-1,y+1)

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


Neighbors of a pixel y
• N4(p) : 4-neighbors of p
(x-1,y), (x,y-1), (x,y+1), (x+1,y) (x+1,y-1) (x+1,y) (x+1,y+1)
• ND(p) : four diagonal neighbors of p
(x-1,y-1),(x-1,y+1), (x+1, y-1),(x+1, y+1)
• N8(p) : 8-neighbors of p Conventional indexing method
N4(p) and ND(p)
Neighbors of a Pixel Neighbors of a Pixel

Neighborhood relation is used to tell adjacent pixels. It is


Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


useful for analyzing regions. 8-neighbors of p:
(x-1,y-1) (x-1,y) (x-1,y+1)

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


(x,y-1) p (x,y+1) (x-1,y)
p (x1,y) (x-1,y1)
(x,y-1) (x,y+1)
(x,y-1) (x,y-1)
N4(p) = (x+1,y-1) (x+1,y) (x+1,y+1) N8(p) = (x,y+1)
(x,y1)
(x+1,y)
(x+1,y) (x1,y-1)
(x+1,y)
(x+1,y+1)
4-neighborhood relation considers only vertical and horizontal neighbors.
8-neighborhood relation considers all neighbor pixels.
Note: q N4(p) implies p N4(q)

Some basic relationships between


Neighbors of a Pixel
pixels
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Connectivity
(x-1,y-1) (x-1,y+1) Diagonal neighbors of p:
• Two pixels are connected if:

p (x1,y1) – They are neighbors (i.e. adjacent in some sense -- e.g.


(x-1,y1) N4(p), N8(p), …)
ND(p) = (x1,y1)
(x+1,y-1) (x+1,y+1)
(x+1,y+1) – Their gray levels satisfy a specified criterion of similarity
(e.g. equality, …)
Diagonal - neighborhood relation considers only diagonal • V is the set of gray-level values used to define adjacency
neighbor pixels.
(e.g. V={1} for adjacency of pixels of value 1)
Some basic relationships Some basic relationships
Adjacency
between pixels between pixels
Adjacency
A pixel p is adjacent to pixel q is they are connected.
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


V: set of gray level values (L), (V is a subset of L.) Two image subsets S1 and S2 are adjacent if some pixel in
3 types of adjacency S1 is adjacent to some pixel in S2
 4- adjacency: 2 pixels p and q with values from V are
4- adjacent if q is in the set N4(p)
 8- adjacency: 2 pixels p and q with values from V are
8- adjacent if q is in the set N8(p)
 m- adjacency: 2 pixels p and q with values from V are
m-adjacent if
1. q is in N4(p), or S1
2. q is in ND(p) and the set N4(p) ∩ N4(q) has no pixels S2

whose values are from V We can define type of adjacency: 4-adjacency, 8-adjacency
or m-adjacency depending on type of connectivity.

Types of Adjacency Types of Adjacency

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

Computer Vision and Image Processing, [email protected]. 2024


from V are 4-adjacent if q is in the set N4(p). two pixels (finding a path between two pixels):
2. 8-adjacency: Two pixels p and q with values  In 8-adjacency way, you can find multiple paths between
two pixels
from V are 8-adjacent if q is in the set N8(p).
 While, in m-adjacency, you can find only one path
3. m-adjacency =(mixed) between two pixels
Two pixels p and q with values from V are m-  So, m-adjacency has eliminated the multiple path
adjacent if : connection that has been generated by the 8-
• q is in N4(p) or adjacency.
• q is in ND(p) and the set N4(p) ∩ N4(q) has no pixel  Two subsets S1 and S2 are adjacent, if some pixel in S1
whose values are from V (no intersection) is adjacent to some pixel in S2. Adjacent means, either
Important Note: the type of adjacency used must 4-, 8- or m-adjacency.
be specified
Some basic relationships Some basic relationships
between pixels between pixels
Adjacency Mixed adjacency is a Types of Adjacency
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


modification of 8-adjacency.  In this example, we can note that to connect between two
pixels (finding a path between two pixels):
4 – adjacency
It is introduced to eliminate
• In 8-adjacency way, you can find multiple paths between
pixels the ambiguities that often two pixels
arise when 8-adjacency is • While, in m-adjacency, you can find only one path
Arrangement used. between two pixels
pixels in a
binary image
 So, m-adjacency has eliminated the multiple path connection
8 – adjacency that has been generated by the 8-adjacency
pixels

m - adjacency  Two subsets S1 and S2 are adjacent, if some pixel in S1 is


m – adjacency pixels adjacent to some pixel in S2. Adjacent means, either 4-, 8- or
pixels
m-adjacency

Some basic relationships Some basic relationships


between pixels between pixels
Examples: Adjacency Examples: Adjacency
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


V = {1, 2} V = {1, 2}

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

Computer Vision and Image Processing, [email protected]. 2024


Foreground and background
• Let R be a subset of pixels in an image, we
call R a region of the image if R is a Suppose that the image contains K disjoint regions
connected set.
Rk none of which touches the image border
Boundary
• The boundary (also called border or contour) of a region R Ru: the union of all regions
is the set of pixels in the region that have one or more
neighbors that are not in R. (Ru)c : is the complement
• 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 So Ru is called foreground
columns of the image.
and (Ru)c : is the background.
Edge
Pixels with derivative values that exceed a preset threshold

Some basic relationships Some basic relationships


between pixels between pixels

Boundary Boundary
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Question 1 Question 2
 In the following arrangement of pixels, are the two  In the following arrangement of pixels, are the two
regions (of 1s) adjacent? (if 8-adjacency is used) parts (of 1s) adjacent? (if 4-adjacency is used)

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

Foreground and background Digital Path


Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


A (digital) path (or curve) from pixel p with coordinates (x,y)
 In the following arrangement of pixels, the two
to pixel q with coordinates (s,t) is a sequence of distinct pixels
regions (of 1s) are disjoint (if 4-adjacency is used)
with coordinates
(X0, Y0), (X1, Y1),…,(Xn, Yn)
1 1 1
foreground
1 0 1 Where (Xi, Yi) and (Xi -1,Yi -1) are adjacent for 1 ≤ i ≤ n.
• Here n is the length of the path.
0 1 0 • If (X0,Y0) = (Xn,Yn)), the path is closed path.
0 0 1 background
• We can define 4-, 8-, and m-paths based on the type of
1 1 1 adjacency used.
1 1 1

Some basic relationships Some basic relationships


between pixels between pixels
Digital Path Digital Path
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


A path from pixel p at (x,y) to pixel q at (s,t) is a sequence 8-path m-path
of distinct pixels: p p p
(x0,y0), (x1,y1), (x2,y2),…, (xn,yn)
such that
(x0,y0) = (x,y) and (xn,yn) = (s,t)
and q q q
(xi,yi) is adjacent to (xi-1,yi-1), i = 1,…,n
q m-path from p to q
p
8-path from p to q
solves this ambiguity
results in some ambiguity

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


depending on type of adjacency.
Some basic relationships Some basic relationships
between pixels between pixels
Example : consider the image segment shown in figure (a). Example : consider the image segment shown in figure (a). Compute
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


length of shortest-4, shortest-8, shortest–m paths between
Compute length of shortest -4, shortest -8, shortest –m paths pixels p & q where v={2, 3}
4 5 6 4 5 4
between pixels p & q where v={1,2} 4 5 6 4 5
q
4
q Shortest-4
3 5 3 4 3 4 3 5 3 4 3 4 Path dose
4 3 5 q 2 4 3 5 q 2 Figure (a)
4 4 4 2 4 3 4 4 4 2 4 3 not exist
3 4 1 4 3 4 1 4 5 3 4 3 3 2 5 3 4 3 3 2
1 5 2 3 1 5 2 3 6 3 5 3 4 6 6 3 5 3 4 6

p 2 1 1 4 p 2 1 1 4 5 4p 2 3 3 6 5 4p 2 3 3 6

Figure (a) Shortest-4 Path dose not exist 4 5 6 4 5 4 4 5 6 4 5 4


q q
4 3 5 q 2 q 3 5 3 4 3 4 3 5 3 4 3 4
4 3 5 2
4 4 4 2 4 3 4 4 4 2 4 3
3 4 1 4 3 4 1 4 Shortest-8
5 3 4 3 3 2 Path= 4 5 3 4 3 3 2
1 5 2 3 1 5 2 3
=5 6 3 5 3 4 6 Shortest-m
6 3 5 3 4 6
p 2 1 1 4 p 2 1 1 4 Path = 5
5 4p 2 3 3 6 5 4p 2 3 3 6
Shortest-8 Path=4 =7
Shortest-m Path =5

Some basic relationships Some basic relationships


between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Assuming there are two image points with coordinates (x, y)
If we have 3 pixels: p, q, z respectively and (s,t). a distance measure is normally conduced for
p with (x,y) evaluating how close two these two pixels are and how they
are related. A number of distance measurements have been
q with (s,t) commonly used for this purpose:
z with (v,w) 1. The Euclidean distance between two 2-D points p(x ,y)
y
 ,    
Then: and q(s,t) is defined as: t

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

Computer Vision and Image Processing, [email protected]. 2024


3. The D8 distance
2. The City-Block distance x p x p
(called the chessboard
between two 2-D points
distance) between p
p(x, y) and q(s, t) can be
 ,      , 
and q is defined as:
calculated as follows: s q s q

 ,     
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).

Some basic relationships Some basic relationships


between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


4. Dm-distance between two points is defined as the shortest
m-path between the points.
In this case the distance two pixels will depend on the
values of the pixels along the path as well as the values of their
1- If P1 and P3 are 0, The m-path Dm distance between P and P4 is 2
neighbors.
2- If P1 = 1 and P3 = 0 The Dm distance between P and P1 P2 P4 is 3
Example
3- If P3=1 and P1 = 0 The Dm distance between P and P2 P3 P4 is 3
Consider the following arrangement of pixels
4- If P3=1 and P1 = 1 The Dm distance between P and P1 P2 P3 P4 is 4
and assume that P, P2, and P4 have value 1 and
that P1 and P3 can have a value of 0 or 1:
Suppose that we consider adjacency of pixels
valued 1 (i.e., v={1} )
Some basic relationships Some basic relationships
between pixels between pixels
Distance Measures
Distance Metric Description Illustration Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Euclidean The Euclidean distance is the 0 0 0 1
Example: Suppose p p(-2,-2) và q(3,4)
p(x,y), q(s,t) straightline distance between two
0 1 0 1 0 1

 ,    
pixels. and q are two pixels.
0 0 0 1

Image Distance transform


Calculate the distance
City Block The city block distance metric measures D4 , D8 and De
p(x,y), q(s,t) measures the path between the
pixels based on a 4-connected 0 0 0 2 1 2
enihborhood. Pixels whose edges
1 0 1
touch are 1 unit apart and pixels 0 1 0
diagonally touching are 2 units 0 0 0 2 1 2

 ,     
apart.
Image Distance transform

Chessboard The chessboard distance metric


measures the path between the 0 0 0 1 1 1
p(x,y), q(s,t) pixels based on an 8-connected
enighborhood. Pixels whose edges 0 1 0 1 0 1

 ,      , 
or corners touch are 1 unit apart. 0 0 0 1 1 1

Image Distance transform

Some basic relationships Some basic relationships


between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Example: Compute the distance between the two pixels using Example: Use the city block distance to prove 4-neighbors?
the three distances:
q:(1,1)
p: (2,2)
De (Euclidian distance) :    Pixel a:  ,        
D4 (City Block distance):    Pixel b:  ,        
Pixel c:  ,        
=2
D8 (chessboard distance) : max(   ,  )=1 Pixel d:  ,        
(because it is one of the 8-neighbors ) Now as a homework try the chessboard distance to proof the
8- neighbors!
Some basic relationships Some basic relationships
between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Example: The pixels with distance D4 ≤ 2 from (x,y) form the Example: D8 distance ≤ 2 from (x,y) form the following
following contours of constant distance. 2 contours of constant distance.
2 2 2 2 2
2 1 2

 ,       ,      , 
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)

Some basic relationships Image Representation &


between pixels Description
Distance Measures 1 1 1 1 1 2 3 2 6 1 1
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Boundary Following
Exercise: 1 1 0 0 1 6 2 3 6 2
1 0 1 0 1 5 3 2 3 6 2 Region Properties
1 0 1 0 1 2 4 3 5 2
1 1 1 1 1 4 5 2 3 6
3 Boundary Segments
f g
Determine:
• 4- adjacency and 8- adjacency: N4(p), N8(p) in image f
4 Run length code & QuadTree Code
• Distance: image f v{1} and image g (v{2,3}, v{2,6})
5 Chain Codes & Shape Numbers
Euclide distance :  ,    

City – Block distance :  ,     


6 Fourier Descriptor
Chess-Board distance :  ,      , 

 Dm distance: v{1}; v{2,3}; v{2,6} Use of Principal Components for Description


7
Company Logo
Image Representation & Image Representation &
Description Description
Objective: Boundary Following
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


To represent and describe information embedded in
an image in other forms that are more suitable than the The boundary is a good representation of an object
image itself. shape and also requires a few memory.
Benefits: We assume
- Easier to understand 1. That we are working with binary images in
- Require fewer memory, faster to be processed
which object and background points are labeled
- More “ready to be used”
What kind of information we can use? 1 and 0, respectively
- Boundary, shape 2. The images are padded with a border of 0s to
- Region eliminate the possibility of an object merging
- Texture with the image border.
- Relation between regions

Image Representation & Image Representation &


Description Description
Boundary Following Image smoothed Smoothed image
Region Properties
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Noisy with 9x9 thresholded using
image averaging mask Otsu’s method
 Once a binary image has been processed we could
obtain properties about the regions in the processed
image.

 Some of those properties are:

Area, centroid, perimeter, perimeter length,


circularity of the region and second circularity
Longest outer Subsampled Connected measure.
boundary boundary points
Image Representation & Image Representation &
Description Description
Region Properties: Area and Centroid Region Properties: Perimeter
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Area A = Sum of all the 1-pixels in the region of o A simple definiton of the perimeter of a region without
interest, say label 2 =8 holes is set of its interior border pixels.
 Centroid is the average location of the pixels in the region o A pixel of a region is a border pixel if it has some
 , )
Centroid =(horizontal center, vertical center)= (
neighboring pixel that is outside the region.

 = (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.

 =(Sum of all the columns


= (2+2+3+3+4+5+6+7)/8= 4
1 1 1 0 0 0 2 0
o When 4-connectivity is used to determine whether a pixel
1 1 1 0 0 0 2 0
positions in the region) / A
inside the region is connected to a pixel outside the
1 1 1 0 0 0 2 0
region, the resulting set of perimeter pixel is 8-connected.
= (5+5+6+6+6+7+7+7)/8 = 6.125 1 1 1 0 0 2 0 0
6 1 1 1 0 0 0 0 0

Image Representation & Image Representation &


Description Description
Region Properties: The length of a perimeter Region Properties: Circularity 1
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


 Circularity 1: With the area A and perimeter P defined, a
 To compute length |P| of perimeter P, the pixels common measure of the circularity of the region is the


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:

Where  and  are the mean and standard deviation of


 Each pair of successive pixels in the sequence
being neighbor, including the first and last pixels. the distance from the centroid of the shape to the shape
boundary and can be computed according to the following
formulas
Image Representation & Image Representation &
Description Description
Region Properties: Circularity 2
Region Properties: Circularity 2
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Labled connected
 Mean radial distantce:
!

components image
    ,  ,  ; %& , '&  %̅ , '̅  %&  %̅ ) '&  '̅ )

"#
 Standard divation of radial distance:
!
Here rows &


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

Image Representation & Image Representation &


Description Description
Polygonal Approximations Polygonal Approximations
o To represent a boundary by straight line segments, and o Minimum perimeter polygons: (Merging and
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


a closed path becomes a polygon. splitting)
o The number of straight-line segments used determines  Merging and splitting are often used together to ensure
the accuracy of the approximation. that vertices appear where they would naturally in the
o Only the minimum required number of sides necessary boundary.
to preserve the needed shape information should be  A least squares criterion to a straight line is used to stop
used (Minimum perimeter polygons). the processing.
o A larger number of sides will only add noise to the model.
Object Boundary divided
boundary into segments
Object boundary Minimum base on extreme
enclosed by cells perimeter polygon
Joining of Resulting
vertices polygon
Image Representation & Image Representation &
Description Description
Signature Signature
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


o The idea behind a signature is to convert a two dimensional o Signatures are invariant to location but will depend on
boundary into a representative one dimensional function.
rotation and scaling.
The signature consists of
repetitions of the pattern  Starting at the point farthest from the reference point or
r() is constant The Secant sec(x) and
Cosecant csc(x) function using the major axis of the region can be used to
r() =A sec  for 0/4 decrease dependence on rotation.
r() =A csc  for /4/2
 Scale invariance can be achieved by either scaling the
signature function to fixed amplitude or by dividing the
function values by the standard deviation of the function.
Distance versus angle signatures

Image Representation & Image Representation &


Description Description
Boundary Segments Moore boundary tracking algorithm
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


(output is ordered sequence of points)
o Decompose a boundary into segments.
o Use of the convex hull of the region enclosed by (1) Let the starting point b0 be the uppermost, leftmost point
the boundary is a powerful tool for robust in the image with label 1, and c0 the west neighbour of b0.
decomposition of the boundary. Note that c0 is always a background point. Examine the 8-
neighbours of b0, starting at c0 and proceeding in a clockwise
direction. Let b1 denote the first neighbour encountered
whose value is 1 and let c1 be the (background) point
immediately preceeding b1 in the sequence. Store the
A region, S, and its convex Partitioned boundary
deficiency (shaded) locations of b0 and b1 for use in Step 5.
Image Representation & Image Representation &
Description Description
Moore boundary tracking algorithm Moore boundary tracking algorithm
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


(output is ordered sequence of points) (output is ordered sequence of points)
(2) Let b = b1 and c = c1.
(3) Let the 8-neighbours of b, starting at c and
proceeding in a clockwise direction, be denoted by n1,
n2, . . . , n8. Then find the first nk labelled 1.
(4) Let b = nk and c = nk-1. Illustration of the first few step in the boundary-
(5) Repeat Steps 3 and 4 until b = b0 and the next following algorithm. The point to be processed next is
boundary point found is b1. The sequence of b points labeled in black, the point yet to be processed are
found when the algorithm stops constitutes the set of gray, and the point found by the algorithm are labeld
ordered boundary points. as gray squares.

Image Representation & Image Representation &


Description Description
Moore boundary tracking algorithm Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


(output is ordered sequence of points) o Produce a pixel wide graph that has the same
The algorithm should NOT stop the first time that b0 is basic shape of the region, like a stick figure of a
encountered again, as illustrated by the following example: human. It can be used to analyze the geometric
structure of a region which has bumps and “arms”.

o Skeletonization, that is the process that reduces


the boundary of a region to a graph (which is a
single pixel thick), often precedes other
Illustration of an erroneous result when the representation schemes and is therefore discussed
stopping rule is such that boundary-following stop first.
when the starting point, b0, is encountered again.
Image Representation & Image Representation &
Description Description
Skeletons Before a thinning algorithm: Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


o Brute force method: Medial axis transformation
Edge points are deleted in an iterative way so that
Consider a region R with boundary B...
• For each point p in R find its closest neighbour in B (1) end points are not removed,
• If p has more than one closest neighbour, then p is part of (2) connectivity is not broken, and
the medial axis
(3) no excessive erosion is caused to the region
Medial axes
(dashed) of three This algorithm thins a binary region, where an edge point
simple regions =1 and a background point =0

Contour point: Edge point (=1) with at least one neighbour


Problem: we have to calculate the distance between every with a value of 0
internal point and every point on the edge of the boundary!

Image Representation & Image Representation &


Description Description
Skeletons Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Before a thinning algorithm: Step 1: Flag a contour point p1 for deletion if the
A contour point is any pixel with value 1 and following conditions are satisfied
having at least one 8-neighbor valued 0. (a ) 2  N ( p1 )  6 ( c ) p 2  p 4  p6  0
Let P9 P2 P3 (b) T ( p1 )  1 (d ) p  p  p  0
4 6 8
P8 P1 P4
N ( p1 )  p2  p3  ...  p8  p9 P7 P6 P5 Illustration of
condition (a) and (b)
N(p1): number of non-zero neighbors of p1. in Eq. In this case
N(p1) = 4
T(p1): The number of 0-1 transitions in the ordered T(p1) = 3
sequence p2, p3, p4, p5, p6 p7,,p8, p9, p2
Image Representation & Image Representation &
Description Description
Skeletons Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Step 2: Flag a contour point p1 for deletion again.
However, conditions (a) and (b) remain the same, A thinning algorithm:
but conditions (c) and (d) are changed to 1. Applying step 1 to flag border points for
deletion
(c' ) p2  p4  p8  0 P9 P2 P3
2. Deleting the flagged points
(d ' ) p2  p6  p8  0
P8 P1 P4
3. Applying step 2 to flag the remaining border
P7 P6 P5
points for deletion
4. Deleting the flagged points
• After step 2 is applied to all border points remaining after
step 1, those that are flagged are deleted (changed to 0) This procedure is applied iteratively until no
• This procedure is applied iteratively until no further points further points are deleted.
are deleted

Image Representation & Image Representation &


Description Description
A thinning algorithm: Skeletons Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Reasons for each of these conditions... o One application of
skeletonization is for character
(a) N(p1)=1 : end point will be deleted! recognition.
o A letter or character is
determined by the center-line
(b) N(p1)=7 : erosion will occur! of its strokes and is unrelated
to the width of the stroke lines.
(c) T(p1)=2 : connectivity will be broken!
Note that N(p1) = 2 here reasons Human leg bone and
for conditions (c), (d), (c’) and (d’) skeleton of the region
shown superimposed
Image Representation & Image Representation &
Description Description
Run length code & QuadTree Code
Skeletons: Examples  Run length code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


 This method is often used to represent image regions or
binary images. An image region R can be simply represented
by a binary matrix:

 /0(, ,) ∈ 
*(, ,)  .
# /0(, ,) ∉ 

 With the representation on a binary image area consisting of


interwoven strings of 0 or 1 called "runs".
 Each circuit has a start address and length in column
format: (<row, column>, length)

Image Representation & Image Representation &


Description Description
Run length code & QuadTree Code Run length code & QuadTree Code
 Run length code  QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


0 1 2 3 4
0
1  Using quad tree, an image area is considered to enclose a
Input: 2 Output: (1,1)1; (1,3)2; (2,0)4; (3,1)2
rectangle. This area is divided into 4 sub-areas (Quadrant).
3
4  If a subregion consists of all black pixles (1) or all white
For example: Input: For image I 8x8 = 64 bytes pixles (0), there is no need to divide further
0 0 0 0 1 1 0 0 (0,4), (1,2), (0,2)  On the contrary, a sub-region that includes both black and
0 0 0 1 1 1 1 0 (0,3), (1,4), (0,1)
0 0 0 1 1 1 1 0 Output: Represented (0,3), (1,4), (0,1) white points is called a non-uniform region, we continue to
0 0 1 1 1 1 1 0 (0,2), (1,5), (0,1)
0 0 1 1 1 1 1 0 as 22 integer pairs = 44 (0,2), (1,5), (0,1) divide it into 4 sub-regions and continue checking.
0 0 0 1 1 1 0 0 (0,3), (1,3), (0,3)
0 0 0 0 1 0 0 0 bytes
0 0 0 0 0 0 0 0 (0,4), (1,1), (0,3)
(0,8)
Image Representation & Image Representation &
Description Description
Run length code & QuadTree Code Run length code & QuadTree Code
 QuadTree Code  QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Root node
 The image representation tree consists of a sequence of Each node is divided
symbols b (black), w (white) and g (grey) accompanied by
into 4 leaf nodes.
symbols encoding 4 sub-regions.
Number of nodes that
 Representation by this method is superior to the above
can be divided:
!
methods, especially compared to run length code codes. Leaf node
 However, calculating measurements of shapes such as
 0 A B C D
perimeter and moment is relatively difficult. 0"#
QuadTree Code
D: number of divisions

Image Representation & Image Representation &


Description Description
Run length code & QuadTree Code Run length code & QuadTree Code
 QuadTree Code  QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


For example: First division For example: Subsequent divisions

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

Computer Vision and Image Processing, [email protected]. 2024


For example: Draw Object
a quad tree Boundary
boundary vertices
(resampling)
A B C D

4-directional 8-directional
chain code chain code

Image Representation & Image Representation &


Description Description
Boundary Description - shape number
Chain Codes & Shape Numbers
• The first difference of a chain-coded
Computer Vision and Image Processing, [email protected]. 2024

• 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


o The chain code of boundary depends on the starting point.
o The shape number of a boundary, generally based on 4- Circular list: 0 3 0 3 2 2 1 1 0
directional Freeman chain codes, is defined as the first ci+1-ci: 3 -3 3 -1 0 -1 0 -1
difference of smallest magnitude. (ci+1-ci ) mod 4: 3 1 3 3 0 3 0 3
o The order n of a shape number is defined as the number of Min magnitude: 0 3 0 3 3 1 3 3 (normalized)
digits in its representation.
o Chain code can be made insensitive Chain code: 0 3 3 2 2 1 0 1
 To the starting point by using circular sequence and the
Circular list: 0 3 3 2 2 1 0 1 0
integer of minimum magnitude
ci+1-ci: 3 0 -1 0 -1 -1 1 -1
 To rotations that are multiples of 90o, by using the first (ci+1-ci ) mod 4: 3 0 3 0 3 3 1 3
difference of the code, called shape number. Min magnitude: 0 3 0 3 3 1 3 3 (normalized)
o Size normalization can be achieved by adjusting the size of the
resampling grid. Therefore shape number of both images is 03033133 of order 8
Ch12-p.368

Image Representation & Image Representation &


Description Description
Boundary Description - shape number Chain Codes & Shape Numbers: Exercise
All shapes of
Computer Vision and Image Processing, [email protected]. 2024 order 4, 6 and
8. The
direction are
? from Fig. and
the dot
− A chain code: 10103322 indicates the
− The first difference = 3133030 starting point.

− Treating a chain code as a circular sequence, we get the first


difference =33133030. The first difference is rotational invariant
− Min magnitude: 03033133
?
Image Representation & Image Representation &
Description Description
Chain Codes & Shape Numbers: Exercise Chain Codes & Shape Numbers: Exercise
All shapes of
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


order 4, 6 and
8. The
direction are ? ?
from Fig. and
the dot
indicates the
starting point.

Image Representation & Image Representation &


Description Description
Chain Codes & Shape Numbers: Exercise Chain Codes & Shape Numbers: Example
Note: the first difference is rotation invariant, but the coded
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

Computer Vision and Image Processing, [email protected]. 2024


is the covariance matrix of the Therefore, for a specified order n, find a rectangle

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

Image Representation & Image Representation &


Description Description
Chain Codes & Shape Numbers: Example Chain Codes & Shape Numbers: Example
Example
Computer Vision and Image Processing, [email protected]. 2024

Example Computer Vision and Image Processing, [email protected]. 2024

2. Find the smallest rectangle


1. Find the basic rectangle for n=18 (boundary) that fits the shape

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

5. Find the difference Shape No.


000310330130031303
6. Find the shape no.
3. Create grid 4. Find the nearest grid
Image Representation & Image Representation &
Description Description
Fourier Descriptor Fourier Descriptor
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


View a coordinate (x, y) as a complex number:
o This is a way of using the Fourier transform to analyze the
shape of a boundary. x = real part and y = imaginary part, then apply the
Fourier transform to a sequence of boundary points.
 The x -y coordinates of the boundary are treated as the
real and imaginary parts of a complex number. Let s(k) be a coordinate
s(k )  x (k )  jy ( k )
 Then the list of coordinates is Fourier transformed using of a boundary point k :
the DFT.
K 1
 The Fourier coefficients are called the Fourier 1
descriptors.
Fourier descriptor : a (u ) 
K
 s ( k )e
k 0
 2uk / K

 The basic shape of the region is determined by the first


several coefficients, which represent lower frequencies. Reconstruction formula
 Higher frequency terms provide information on the fine Boundary 1 K 1
detail of the boundary. points
s(k )  
K k 0
a (u )e 2uk / K

Image Representation & Image Representation &


Description Description
Fourier Descriptor
Examples of reconstruction from Fourier descriptors Fourier Descriptor
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Fourier descriptors are not directly insensitive to
P 1
1 geometric transformation, but the changes in these
sˆ(k ) 
K
 a (u )e 
k 0
2 uk / K

parameters can be related to simple transformations on the


descriptors by using the following properties:
P is the number of
Fourier coefficients Transformation Boundary Fourier Descriptor
used to reconstruct Identity  *
 JK  *   * JK
the boundary
Rotation 

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

Computer Vision and Image Processing, [email protected]. 2024


K 1
n ( r )   ( ri  m) g ( ri ) The first moment = mean
n
1. Some simple regional descriptors (discussed above)
i 0 The second moment = variance - Area of the region
where K 1 - Length of the boundary (perimeter) of the region
m   ri g ( ri ) - Compactness
i 0 A( R )
C 2
Boundary P ( R)
segment 1D graph where A (R) and P (R) = area and perimeter of region R
Example: a circle is the most compact shape with C = 1/4p

1. Convert a boundary segment into 1D graph 2. Topological Descriptors


2. View a 1D graph as a PDF function 3. Texture
3. Compute the nth order moment of the graph 4. Moments of 2D Functions

Image Representation & Image Representation &


Description Description
Regional Descriptors: Examples
Topological
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


White pixels represent Used to describe holes and connected components of the
“light of the cities” region
Euler number (E):
A region with E CH
% of white pixels
Region no. compared to the two holes
total white pixels C = the number of connected
components
1 20.4% H = the number of holes
2 64.0%
3 4.9%
4 10.7%
A region with
three connected
components
Infrared image of America at night
Image Representation & Image Representation &
Description Description
Topological Topological: Example
E = -1
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Euler Formula Original image: After intensity
Infrared image Thresholding
Of Washington (1591
V Q  F  C  H  E D.C. area connected
components
with 39 holes)
E=0 V = the number of vertices Euler no. =
Q = the number of edges 1552
F = the number of faces
The largest
connected
area
(8479 Pixels) After thinning
(Hudson river)

E = -2

Image Representation & Image Representation &


Description Description
Texture Texture: Statistical Approaches
Purpose: to describe “texture” of the region, e.g., optical We can use statistical moments computed from an image histogram:
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


microscope images. K 1
Probability Density Functions: PDF
n ( z )   ( zi  m)n p( zi )
i 0 z = intensity
where K 1 p(z) = PDF or histogram of z
m   zi p( zi )
B C
i 0
A
Example: The 2nd moment = variance  measure “smoothness”
The 3rd moment  measure “skewness”
The 4th moment  measure “uniformity” (flatness)

Texture Mean Standard R Third Uniformity Entropy


deviation (normalized) moment
A Smooth 82.64 11.79 0.002 -0.105 0.026 5.434
Cholesterol Microprocessor B Coarse 143.56 74.63 0.079 -0.151 0.005 7.783
Superconductor
(smooth texture) (coarse texture) (regular texture) C Regular 99.72 33.73 0.017 0.750 0.013 6.674
Image Representation & Image Representation &
Description Description
Texture: Spectral (Fourier) Approaches Texture: Spectral (Fourier) Approaches
Concept: convert 2D spectrum into 1D graphs
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Original 2D Spectrum
Fourier image (Fourier Tr.)
Original FFT2D Divide into areas
coefficient
image +FFTSHIFT by angles
image

Divide into areas by radius Sum all pixels S(r) S(q)


in each area

R0
S ( )   Sr ( )
r 1
Another Another
 image S(q)
S ( r )   S ( r )
Sum all pixels in each area  0

Image Representation & Image Representation &


Description Description
Moments of Two-D Functions Invariant Moments of Two-D Functions
The moment of order p + q The normalized central moments of order p + q
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


 pq
m pq   x p y q f ( x, y ) x
m10
y
m01  pq  pq where   1
x y m00 m00 00 2
Invariant moments: independent of rotation, translation, scaling,
The central moments of order p + q
and reflection
 pq   ( x  x ) p ( y  y ) q f ( x, y ) 1  20  02 2  20  02 2  4112
x y
3  30  312 2  321  03 2 4  30  12 2  21  03 2
00  m00 01  10  0
11  m11  x m01  m11  ym10 12  m12  2 ym11  x m02  2 y m10 2

5  30  312 30  12  30  12 2  321  03 2  
20  m20  x m10 02  m02  ym01
321  03 21  03 3  12   21  03
2

2

30  m30  3x m20  2 x 2m10 30

21  m21  2 x m11  ym20  2 x m01


2
03  m03  3 ym02  2 y m01 2 
6  20  02  30  12 2  21  03 2  
411 30  12 21  03 
Image Representation & Image Representation &
Description Description
Invariant Moments of Two-D Functions: Example Invariant Original Half Size Mirrored Rotated 2o Rotated 45o
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


3. Mirrored (Log)
∅
1. Original image 2. Half size

6.249 6.226 6.919 6.253 6.318

∅
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

Image Representation & Image Representation &


Description Description
Use of Principal Components for Description Use of Principal Components for Description
Purpose: to reduce dimensionality of a vector image while Components transformation Let y  A (x  m x )
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


maintaining information as much as possible.
Where A is created from eigenvectors of Cx as follows
Row 1 contain the 1st eigenvector with the largest eigenvalue.
Let
Row 2 contain the 2nd eigenvector with the 2nd largest
x  [ x1 x2 ... xn ]T eigenvalue.….
Then we get 1 0 ... 0 
Mean:
1 K m y  E{y}  0 0  ... 0 
m x  E{x}  x k and Cy   1 
K k 1  ... ...
... ... 
C y  AC x A T
 
 0 ...... 1 
Covariance matrix
K
Then elements ofy  A ( x  m x ) are uncorrelated. The
1
C x  E{(x  m x )( x  m x ) } 
T

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

Computer Vision and Image Processing, [email protected]. 2024


Eigenvector and Eigenvalue from an airborne
Eigenvector and eigenvalue of Matrix C are defined as Scanner.

Let C be a matrix of size NxN and e be a vector of size Nx1.


Channel Wavelength band
If (microns)
Ce  e 1 0.40-0.44
2 0.62-0.66
3 0.66-0.72
Where l is a constant 4 0.80-1.00
5 1.00-1.40
6 2.00-2.60
We call e as an eigenvector and l as eigenvalue of C

Image Representation & Image Representation &


Description Description
Principal Components: Examples Principal Components: Examples
Computer Vision and Image Processing, [email protected]. 2024

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

Original image After components transform


Image Representation & Image Representation &
Description Description
Principal Components: Examples Relational Descriptors
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


An object Coded
structure
A simple
staircase
structure

Object rotated by using Sample


Eq. The net effect is to derivation for
align the object along rules
its eigen axes SaA,
Eigenvectors AbS, and
Ab

Image Representation & Image Representation &


Description Description
Relational Descriptors Relational Descriptors
A simple tree with root $ and frontier xy.
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Abstracted
primitives.
Code a region Tree representation obtained by
Operations
boundary with using the relationship “inside of”
among primitives
directed line
segments
A set of specific
primitives.

Steps in building
a structure.
A simple composite region
[email protected]

Company
LOGO
Some basic relationships between
(COMPUTER VISION) pixels

Introduction to

Computer Vision and Image Processing, [email protected]. 2024


Neighbors of a pixel, Adjacency and
1
Chapter 1: Connectivity
Computer vision 2 Regions, Boundaries, Edge

Some basic relationships between pixels 3 Foreground and background

ThS: TRẦN VĂN HÙNG 4 Digital path


Email: [email protected]
E-Learning: Trần Văn Hùng 5 Distance Measures
ocw.fet.iuh.edu.vn
Company
6 Image Representation & Description
LOGO
Company Logo

Some basic relationships between


pixels Basic Relationship of Pixels

Neighbors of a pixel (0,0) x


Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


• Some of the points in ND(p), N4(p) and N8(p) fall outside the
image if (x,y) is on the border of the image.
(x-1,y-1) (x-1,y) (x-1,y+1)

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


Neighbors of a pixel y
• N4(p) : 4-neighbors of p
(x-1,y), (x,y-1), (x,y+1), (x+1,y) (x+1,y-1) (x+1,y) (x+1,y+1)
• ND(p) : four diagonal neighbors of p
(x-1,y-1),(x-1,y+1), (x+1, y-1),(x+1, y+1)
• N8(p) : 8-neighbors of p Conventional indexing method
N4(p) and ND(p)
Neighbors of a Pixel Neighbors of a Pixel

Neighborhood relation is used to tell adjacent pixels. It is


Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


useful for analyzing regions. 8-neighbors of p:
(x-1,y-1) (x-1,y) (x-1,y+1)

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


(x,y-1) p (x,y+1) (x-1,y)
p (x1,y) (x-1,y1)
(x,y-1) (x,y+1)
(x,y-1) (x,y-1)
N4(p) = (x+1,y-1) (x+1,y) (x+1,y+1) N8(p) = (x,y+1)
(x,y1)
(x+1,y)
(x+1,y) (x1,y-1)
(x+1,y)
(x+1,y+1)
4-neighborhood relation considers only vertical and horizontal neighbors.
8-neighborhood relation considers all neighbor pixels.
Note: q N4(p) implies p N4(q)

Some basic relationships between


Neighbors of a Pixel
pixels
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Connectivity
(x-1,y-1) (x-1,y+1) Diagonal neighbors of p:
• Two pixels are connected if:

p (x1,y1) – They are neighbors (i.e. adjacent in some sense -- e.g.


(x-1,y1) N4(p), N8(p), …)
ND(p) = (x1,y1)
(x+1,y-1) (x+1,y+1)
(x+1,y+1) – Their gray levels satisfy a specified criterion of similarity
(e.g. equality, …)
Diagonal - neighborhood relation considers only diagonal • V is the set of gray-level values used to define adjacency
neighbor pixels.
(e.g. V={1} for adjacency of pixels of value 1)
Some basic relationships Some basic relationships
Adjacency
between pixels between pixels
Adjacency
A pixel p is adjacent to pixel q is they are connected.
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


V: set of gray level values (L), (V is a subset of L.) Two image subsets S1 and S2 are adjacent if some pixel in
3 types of adjacency S1 is adjacent to some pixel in S2
 4- adjacency: 2 pixels p and q with values from V are
4- adjacent if q is in the set N4(p)
 8- adjacency: 2 pixels p and q with values from V are
8- adjacent if q is in the set N8(p)
 m- adjacency: 2 pixels p and q with values from V are
m-adjacent if
1. q is in N4(p), or S1
2. q is in ND(p) and the set N4(p) ∩ N4(q) has no pixels S2

whose values are from V We can define type of adjacency: 4-adjacency, 8-adjacency
or m-adjacency depending on type of connectivity.

Types of Adjacency Types of Adjacency

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

Computer Vision and Image Processing, [email protected]. 2024


from V are 4-adjacent if q is in the set N4(p). two pixels (finding a path between two pixels):
2. 8-adjacency: Two pixels p and q with values  In 8-adjacency way, you can find multiple paths between
two pixels
from V are 8-adjacent if q is in the set N8(p).
 While, in m-adjacency, you can find only one path
3. m-adjacency =(mixed) between two pixels
Two pixels p and q with values from V are m-  So, m-adjacency has eliminated the multiple path
adjacent if : connection that has been generated by the 8-
• q is in N4(p) or adjacency.
• q is in ND(p) and the set N4(p) ∩ N4(q) has no pixel  Two subsets S1 and S2 are adjacent, if some pixel in S1
whose values are from V (no intersection) is adjacent to some pixel in S2. Adjacent means, either
Important Note: the type of adjacency used must 4-, 8- or m-adjacency.
be specified
Some basic relationships Some basic relationships
between pixels between pixels
Adjacency Mixed adjacency is a Types of Adjacency
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


modification of 8-adjacency.  In this example, we can note that to connect between two
pixels (finding a path between two pixels):
4 – adjacency
It is introduced to eliminate
• In 8-adjacency way, you can find multiple paths between
pixels the ambiguities that often two pixels
arise when 8-adjacency is • While, in m-adjacency, you can find only one path
Arrangement used. between two pixels
pixels in a
binary image
 So, m-adjacency has eliminated the multiple path connection
8 – adjacency that has been generated by the 8-adjacency
pixels

m - adjacency  Two subsets S1 and S2 are adjacent, if some pixel in S1 is


m – adjacency pixels adjacent to some pixel in S2. Adjacent means, either 4-, 8- or
pixels
m-adjacency

Some basic relationships Some basic relationships


between pixels between pixels
Examples: Adjacency Examples: Adjacency
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


V = {1, 2} V = {1, 2}

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

Computer Vision and Image Processing, [email protected]. 2024


Foreground and background
• Let R be a subset of pixels in an image, we
call R a region of the image if R is a Suppose that the image contains K disjoint regions
connected set.
Rk none of which touches the image border
Boundary
• The boundary (also called border or contour) of a region R Ru: the union of all regions
is the set of pixels in the region that have one or more
neighbors that are not in R. (Ru)c : is the complement
• 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 So Ru is called foreground
columns of the image.
and (Ru)c : is the background.
Edge
Pixels with derivative values that exceed a preset threshold

Some basic relationships Some basic relationships


between pixels between pixels

Boundary Boundary
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Question 1 Question 2
 In the following arrangement of pixels, are the two  In the following arrangement of pixels, are the two
regions (of 1s) adjacent? (if 8-adjacency is used) parts (of 1s) adjacent? (if 4-adjacency is used)

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

Foreground and background Digital Path


Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


A (digital) path (or curve) from pixel p with coordinates (x,y)
 In the following arrangement of pixels, the two
to pixel q with coordinates (s,t) is a sequence of distinct pixels
regions (of 1s) are disjoint (if 4-adjacency is used)
with coordinates
(X0, Y0), (X1, Y1),…,(Xn, Yn)
1 1 1
foreground
1 0 1 Where (Xi, Yi) and (Xi -1,Yi -1) are adjacent for 1 ≤ i ≤ n.
• Here n is the length of the path.
0 1 0 • If (X0,Y0) = (Xn,Yn)), the path is closed path.
0 0 1 background
• We can define 4-, 8-, and m-paths based on the type of
1 1 1 adjacency used.
1 1 1

Some basic relationships Some basic relationships


between pixels between pixels
Digital Path Digital Path
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


A path from pixel p at (x,y) to pixel q at (s,t) is a sequence 8-path m-path
of distinct pixels: p p p
(x0,y0), (x1,y1), (x2,y2),…, (xn,yn)
such that
(x0,y0) = (x,y) and (xn,yn) = (s,t)
and q q q
(xi,yi) is adjacent to (xi-1,yi-1), i = 1,…,n
q m-path from p to q
p
8-path from p to q
solves this ambiguity
results in some ambiguity

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


depending on type of adjacency.
Some basic relationships Some basic relationships
between pixels between pixels
Example : consider the image segment shown in figure (a). Example : consider the image segment shown in figure (a). Compute
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


length of shortest-4, shortest-8, shortest–m paths between
Compute length of shortest -4, shortest -8, shortest –m paths pixels p & q where v={2, 3}
4 5 6 4 5 4
between pixels p & q where v={1,2} 4 5 6 4 5
q
4
q Shortest-4
3 5 3 4 3 4 3 5 3 4 3 4 Path dose
4 3 5 q 2 4 3 5 q 2 Figure (a)
4 4 4 2 4 3 4 4 4 2 4 3 not exist
3 4 1 4 3 4 1 4 5 3 4 3 3 2 5 3 4 3 3 2
1 5 2 3 1 5 2 3 6 3 5 3 4 6 6 3 5 3 4 6

p 2 1 1 4 p 2 1 1 4 5 4p 2 3 3 6 5 4p 2 3 3 6

Figure (a) Shortest-4 Path dose not exist 4 5 6 4 5 4 4 5 6 4 5 4


q q
4 3 5 q 2 q 3 5 3 4 3 4 3 5 3 4 3 4
4 3 5 2
4 4 4 2 4 3 4 4 4 2 4 3
3 4 1 4 3 4 1 4 Shortest-8
5 3 4 3 3 2 Path= 4 5 3 4 3 3 2
1 5 2 3 1 5 2 3
=5 6 3 5 3 4 6 Shortest-m
6 3 5 3 4 6
p 2 1 1 4 p 2 1 1 4 Path = 5
5 4p 2 3 3 6 5 4p 2 3 3 6
Shortest-8 Path=4 =7
Shortest-m Path =5

Some basic relationships Some basic relationships


between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Assuming there are two image points with coordinates (x, y)
If we have 3 pixels: p, q, z respectively and (s,t). a distance measure is normally conduced for
p with (x,y) evaluating how close two these two pixels are and how they
are related. A number of distance measurements have been
q with (s,t) commonly used for this purpose:
z with (v,w) 1. The Euclidean distance between two 2-D points p(x ,y)
y
 ,    
Then: and q(s,t) is defined as: t

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

Computer Vision and Image Processing, [email protected]. 2024


3. The D8 distance
2. The City-Block distance x p x p
(called the chessboard
between two 2-D points
distance) between p
p(x, y) and q(s, t) can be
 ,      , 
and q is defined as:
calculated as follows: s q s q

 ,     
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).

Some basic relationships Some basic relationships


between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


4. Dm-distance between two points is defined as the shortest
m-path between the points.
In this case the distance two pixels will depend on the
values of the pixels along the path as well as the values of their
1- If P1 and P3 are 0, The m-path Dm distance between P and P4 is 2
neighbors.
2- If P1 = 1 and P3 = 0 The Dm distance between P and P1 P2 P4 is 3
Example
3- If P3=1 and P1 = 0 The Dm distance between P and P2 P3 P4 is 3
Consider the following arrangement of pixels
4- If P3=1 and P1 = 1 The Dm distance between P and P1 P2 P3 P4 is 4
and assume that P, P2, and P4 have value 1 and
that P1 and P3 can have a value of 0 or 1:
Suppose that we consider adjacency of pixels
valued 1 (i.e., v={1} )
Some basic relationships Some basic relationships
between pixels between pixels
Distance Measures
Distance Metric Description Illustration Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Euclidean The Euclidean distance is the 0 0 0 1
Example: Suppose p p(-2,-2) và q(3,4)
p(x,y), q(s,t) straightline distance between two
0 1 0 1 0 1

 ,    
pixels. and q are two pixels.
0 0 0 1

Image Distance transform


Calculate the distance
City Block The city block distance metric measures D4 , D8 and De
p(x,y), q(s,t) measures the path between the
pixels based on a 4-connected 0 0 0 2 1 2
enihborhood. Pixels whose edges
1 0 1
touch are 1 unit apart and pixels 0 1 0
diagonally touching are 2 units 0 0 0 2 1 2

 ,     
apart.
Image Distance transform

Chessboard The chessboard distance metric


measures the path between the 0 0 0 1 1 1
p(x,y), q(s,t) pixels based on an 8-connected
enighborhood. Pixels whose edges 0 1 0 1 0 1

 ,      , 
or corners touch are 1 unit apart. 0 0 0 1 1 1

Image Distance transform

Some basic relationships Some basic relationships


between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Example: Compute the distance between the two pixels using Example: Use the city block distance to prove 4-neighbors?
the three distances:
q:(1,1)
p: (2,2)
De (Euclidian distance) :    Pixel a:  ,        
D4 (City Block distance):    Pixel b:  ,        
Pixel c:  ,        
=2
D8 (chessboard distance) : max(   ,  )=1 Pixel d:  ,        
(because it is one of the 8-neighbors ) Now as a homework try the chessboard distance to proof the
8- neighbors!
Some basic relationships Some basic relationships
between pixels between pixels
Distance Measures Distance Measures
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Example: The pixels with distance D4 ≤ 2 from (x,y) form the Example: D8 distance ≤ 2 from (x,y) form the following
following contours of constant distance. 2 contours of constant distance.
2 2 2 2 2
2 1 2

 ,       ,      , 
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)

Some basic relationships Image Representation &


between pixels Description
Distance Measures 1 1 1 1 1 2 3 2 6 1 1
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Boundary Following
Exercise: 1 1 0 0 1 6 2 3 6 2
1 0 1 0 1 5 3 2 3 6 2 Region Properties
1 0 1 0 1 2 4 3 5 2
1 1 1 1 1 4 5 2 3 6
3 Boundary Segments
f g
Determine:
• 4- adjacency and 8- adjacency: N4(p), N8(p) in image f
4 Run length code & QuadTree Code
• Distance: image f v{1} and image g (v{2,3}, v{2,6})
5 Chain Codes & Shape Numbers
Euclide distance :  ,    

City – Block distance :  ,     


6 Fourier Descriptor
Chess-Board distance :  ,      , 

 Dm distance: v{1}; v{2,3}; v{2,6} Use of Principal Components for Description


7
Company Logo
Image Representation & Image Representation &
Description Description
Objective: Boundary Following
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


To represent and describe information embedded in
an image in other forms that are more suitable than the The boundary is a good representation of an object
image itself. shape and also requires a few memory.
Benefits: We assume
- Easier to understand 1. That we are working with binary images in
- Require fewer memory, faster to be processed
which object and background points are labeled
- More “ready to be used”
What kind of information we can use? 1 and 0, respectively
- Boundary, shape 2. The images are padded with a border of 0s to
- Region eliminate the possibility of an object merging
- Texture with the image border.
- Relation between regions

Image Representation & Image Representation &


Description Description
Boundary Following Image smoothed Smoothed image
Region Properties
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Noisy with 9x9 thresholded using
image averaging mask Otsu’s method
Once a binary image has been processed we
could obtain properties about the regions in the
processed image.

Some of those properties are:

Area, centroid, perimeter, perimeter length,


circularity of the region and second circularity
Longest outer Subsampled Connected
boundary boundary points
measure.
Image Representation & Image Representation &
Description Description
Region Properties: Area and Centroid Region Properties: Perimeter
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Area A = Sum of all the 1-pixels in the region of o A simple definiton of the perimeter of a region without
interest, say label 2 =8 holes is set of its interior border pixels.
 Centroid is the average location of the pixels in the region o A pixel of a region is a border pixel if it has some
 , )
Centroid =(horizontal center, vertical center)= (
neighboring pixel that is outside the region.

 = (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.

 =(Sum of all the columns


= (2+2+3+3+4+5+6+7)/8= 4
1 1 1 0 0 0 2 0
o When 4-connectivity is used to determine whether a pixel
1 1 1 0 0 0 2 0
positions in the region) / A
inside the region is connected to a pixel outside the
1 1 1 0 0 0 2 0
region, the resulting set of perimeter pixel is 8-connected.
= (5+5+6+6+6+7+7+7)/8 = 6.125 1 1 1 0 0 2 0 0
6 1 1 1 0 0 0 0 0

Image Representation & Image Representation &


Description Description
Region Properties: The length of a perimeter Region Properties: Circularity 1
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


 Circularity 1: With the area A and perimeter P defined, a
 To compute length |P| of perimeter P, the pixels common measure of the circularity of the region is the


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:

Where  and  are the mean and standard deviation of


 Each pair of successive pixels in the sequence
being neighbor, including the first and last pixels. the distance from the centroid of the shape to the shape
boundary and can be computed according to the following
formulas
Image Representation & Image Representation &
Description Description
Region Properties: Circularity 2
Region Properties: Circularity 2
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Labled connected
 Mean radial distantce:
!

components image
    ,  ,  ; %& , '&  %̅ , '̅  %&  %̅ ) '&  '̅ )

"#
 Standard divation of radial distance:
!
Here rows &


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

Image Representation & Image Representation &


Description Description
Polygonal Approximations Polygonal Approximations
o To represent a boundary by straight line segments, and o Minimum perimeter polygons: (Merging and
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


a closed path becomes a polygon. splitting)
o The number of straight-line segments used determines  Merging and splitting are often used together to ensure
the accuracy of the approximation. that vertices appear where they would naturally in the
o Only the minimum required number of sides necessary boundary.
to preserve the needed shape information should be  A least squares criterion to a straight line is used to stop
used (Minimum perimeter polygons). the processing.
o A larger number of sides will only add noise to the model.
Object Boundary divided
boundary into segments
Object boundary Minimum base on extreme
enclosed by cells perimeter polygon
Joining of Resulting
vertices polygon
Image Representation & Image Representation &
Description Description
Signature Signature
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


o The idea behind a signature is to convert a two dimensional o Signatures are invariant to location but will depend on
boundary into a representative one dimensional function.
rotation and scaling.
The signature consists of
repetitions of the pattern  Starting at the point farthest from the reference point or
r() is constant The Secant sec(x) and
Cosecant csc(x) function using the major axis of the region can be used to
r() =A sec  for 0/4 decrease dependence on rotation.
r() =A csc  for /4/2
 Scale invariance can be achieved by either scaling the
signature function to fixed amplitude or by dividing the
function values by the standard deviation of the function.
Distance versus angle signatures

Image Representation & Image Representation &


Description Description
Boundary Segments Moore boundary tracking algorithm
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


(output is ordered sequence of points)
o Decompose a boundary into segments.
o Use of the convex hull of the region enclosed by (1) Let the starting point b0 be the uppermost, leftmost point
the boundary is a powerful tool for robust in the image with label 1, and c0 the west neighbour of b0.
decomposition of the boundary. Note that c0 is always a background point. Examine the 8-
neighbours of b0, starting at c0 and proceeding in a clockwise
direction. Let b1 denote the first neighbour encountered
whose value is 1 and let c1 be the (background) point
immediately preceeding b1 in the sequence. Store the
A region, S, and its convex Partitioned boundary
deficiency (shaded) locations of b0 and b1 for use in Step 5.
Image Representation & Image Representation &
Description Description
Moore boundary tracking algorithm Moore boundary tracking algorithm
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


(output is ordered sequence of points) (output is ordered sequence of points)
(2) Let b = b1 and c = c1.
(3) Let the 8-neighbours of b, starting at c and
proceeding in a clockwise direction, be denoted by n1,
n2, . . . , n8. Then find the first nk labelled 1.
(4) Let b = nk and c = nk-1. Illustration of the first few step in the boundary-
(5) Repeat Steps 3 and 4 until b = b0 and the next following algorithm. The point to be processed next is
boundary point found is b1. The sequence of b points labeled in black, the point yet to be processed are
found when the algorithm stops constitutes the set of gray, and the point found by the algorithm are labeld
ordered boundary points. as gray squares.

Image Representation & Image Representation &


Description Description
Moore boundary tracking algorithm Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


(output is ordered sequence of points) o Produce a pixel wide graph that has the same
The algorithm should NOT stop the first time that b0 is basic shape of the region, like a stick figure of a
encountered again, as illustrated by the following example: human. It can be used to analyze the geometric
structure of a region which has bumps and “arms”.

o Skeletonization, that is the process that reduces


the boundary of a region to a graph (which is a
single pixel thick), often precedes other
Illustration of an erroneous result when the representation schemes and is therefore discussed
stopping rule is such that boundary-following stop first.
when the starting point, b0, is encountered again.
Image Representation & Image Representation &
Description Description
Skeletons Before a thinning algorithm: Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


o Brute force method: Medial axis transformation
Edge points are deleted in an iterative way so that
Consider a region R with boundary B...
• For each point p in R find its closest neighbour in B (1) end points are not removed,
• If p has more than one closest neighbour, then p is part of (2) connectivity is not broken, and
the medial axis
(3) no excessive erosion is caused to the region
Medial axes
(dashed) of three This algorithm thins a binary region, where an edge point
simple regions =1 and a background point =0

Contour point: Edge point (=1) with at least one neighbour


Problem: we have to calculate the distance between every with a value of 0
internal point and every point on the edge of the boundary!

Image Representation & Image Representation &


Description Description
Skeletons Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Before a thinning algorithm: Step 1: Flag a contour point p1 for deletion if the
A contour point is any pixel with value 1 and following conditions are satisfied
having at least one 8-neighbor valued 0. (a ) 2  N ( p1 )  6 ( c ) p 2  p 4  p6  0
Let P9 P2 P3 (b) T ( p1 )  1 (d ) p  p  p  0
4 6 8
P8 P1 P4
N ( p1 )  p2  p3  ...  p8  p9 P7 P6 P5 Illustration of
condition (a) and (b)
N(p1): number of non-zero neighbors of p1. in Eq. In this case
N(p1) = 4
T(p1): The number of 0-1 transitions in the ordered T(p1) = 3
sequence p2, p3, p4, p5, p6 p7,,p8, p9, p2
Image Representation & Image Representation &
Description Description
Skeletons Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Step 2: Flag a contour point p1 for deletion again.
However, conditions (a) and (b) remain the same, A thinning algorithm:
but conditions (c) and (d) are changed to 1. Applying step 1 to flag border points for
deletion
(c' ) p2  p4  p8  0 P9 P2 P3
2. Deleting the flagged points
(d ' ) p2  p6  p8  0
P8 P1 P4
3. Applying step 2 to flag the remaining border
P7 P6 P5
points for deletion
4. Deleting the flagged points
• After step 2 is applied to all border points remaining after
step 1, those that are flagged are deleted (changed to 0) This procedure is applied iteratively until no
• This procedure is applied iteratively until no further points further points are deleted.
are deleted

Image Representation & Image Representation &


Description Description
A thinning algorithm: Skeletons Skeletons
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Reasons for each of these conditions... o One application of
skeletonization is for character
(a) N(p1)=1 : end point will be deleted! recognition.
o A letter or character is
determined by the center-line
(b) N(p1)=7 : erosion will occur! of its strokes and is unrelated
to the width of the stroke lines.
(c) T(p1)=2 : connectivity will be broken!
Note that N(p1) = 2 here reasons Human leg bone and
for conditions (c), (d), (c’) and (d’) skeleton of the region
shown superimposed
Image Representation & Image Representation &
Description Description
Run length code & QuadTree Code
Skeletons: Examples  Run length code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


 This method is often used to represent image regions or
binary images. An image region R can be simply represented
by a binary matrix:

 /0(, ,) ∈ 
*(, ,)  .
# /0(, ,) ∉ 

 With the representation on a binary image area consisting of


interwoven strings of 0 or 1 called "runs".
 Each circuit has a start address and length in column
format: (<row, column>, length)

Image Representation & Image Representation &


Description Description
Run length code & QuadTree Code Run length code & QuadTree Code
 Run length code  QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


0 1 2 3 4
0  The quadtree method is used to represent homogeneous
1
Input: 2 Output: (1,1)1; (1,3)2; (2,0)4; (3,1)2 regions in an image
3
4
 Using quadtree, an image area is considered to enclose a
rectangle. This area is divided into 4 sub-areas (Quadrant).
For example: Input: For image I (8x8) = 64 bytes
 If a subregion consists of all black pixles (1) or all white
0 0 0 0 1 1 0 0 (0,4), (1,2), (0,2)
0 0 0 1 1 1 1 0 (0,3), (1,4), (0,1) pixles (0), there is no need to divide further
0 0 0 1 1 1 1 0 Output: Represented (0,3), (1,4), (0,1)
0 0 1 1 1 1 1 0 (0,2), (1,5), (0,1)  On the contrary, a sub-region that includes both black and
0 0 1 1 1 1 1 0 as 22 integer pairs = 44 (0,2), (1,5), (0,1)
0 0 0 1 1 1 0 0 (0,3), (1,3), (0,3) white points is called a non-uniform region, we continue to
0 0 0 0 1 0 0 0 bytes
0 0 0 0 0 0 0 0 (0,4), (1,1), (0,3)
(0,8) divide it into 4 sub-regions and continue checking.
Image Representation & Image Representation &
Description Description
Run length code & QuadTree Code Run length code & QuadTree Code
 QuadTree Code  QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Root node
 The image representation tree consists of a sequence of Each node is divided
symbols b (black), w (white) and g (grey) accompanied by
into 4 leaf nodes.
symbols encoding 4 sub-regions.
Number of nodes that
 Representation by this method is superior to the above
can be divided:
!
methods, especially compared to run length code codes. Leaf node
 However, calculating measurements of shapes such as
 0 A B C D
perimeter and moment is relatively difficult. 0"#
QuadTree Code
D: number of divisions

Image Representation & Image Representation &


Description Description
Run length code & QuadTree Code Run length code & QuadTree Code
 QuadTree Code  QuadTree Code
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


For example: First division For example: Subsequent divisions

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

Computer Vision and Image Processing, [email protected]. 2024


For example: Draw Object
a quad tree Boundary
boundary vertices
(resampling)
A B C D

4-directional 8-directional
chain code chain code

Image Representation & Image Representation &


Description Description
Boundary Description - shape number
Chain Codes & Shape Numbers
• The first difference of a chain-coded
Computer Vision and Image Processing, [email protected]. 2024

• 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


o The chain code of boundary depends on the starting point.
o The shape number of a boundary, generally based on 4- Circular list: 0 3 0 3 2 2 1 1 0
directional Freeman chain codes, is defined as the first ci+1-ci: 3 -3 3 -1 0 -1 0 -1
difference of smallest magnitude. (ci+1-ci ) mod 4: 3 1 3 3 0 3 0 3
o The order n of a shape number is defined as the number of Min magnitude: 0 3 0 3 3 1 3 3 (normalized)
digits in its representation.
o Chain code can be made insensitive Chain code: 0 3 3 2 2 1 0 1
 To the starting point by using circular sequence and the
Circular list: 0 3 3 2 2 1 0 1 0
integer of minimum magnitude
ci+1-ci: 3 0 -1 0 -1 -1 1 -1
 To rotations that are multiples of 90o, by using the first (ci+1-ci ) mod 4: 3 0 3 0 3 3 1 3
difference of the code, called shape number. Min magnitude: 0 3 0 3 3 1 3 3 (normalized)
o Size normalization can be achieved by adjusting the size of the
resampling grid. Therefore shape number of both images is 03033133 of order 8
Ch12-p.368

Image Representation & Image Representation &


Description Description
Boundary Description - shape number Chain Codes & Shape Numbers: Exercise
All shapes of
Computer Vision and Image Processing, [email protected]. 2024 order 4, 6 and
8. The
direction are
? from Fig. and
the dot
− A chain code: 10103322 indicates the
− The first difference = 3133030 starting point.

− Treating a chain code as a circular sequence, we get the first


difference =33133030. The first difference is rotational invariant
− Min magnitude: 03033133
?
Image Representation & Image Representation &
Description Description
Chain Codes & Shape Numbers: Exercise Chain Codes & Shape Numbers: Exercise
All shapes of
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


order 4, 6 and
8. The
direction are ? ?
from Fig. and
the dot
indicates the
starting point.

Image Representation & Image Representation &


Description Description
Chain Codes & Shape Numbers: Exercise Chain Codes & Shape Numbers: Example
Note: the first difference is rotation invariant, but the coded
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

Computer Vision and Image Processing, [email protected]. 2024


is the covariance matrix of the Therefore, for a specified order n, find a rectangle

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

Image Representation & Image Representation &


Description Description
Chain Codes & Shape Numbers: Example Chain Codes & Shape Numbers: Example
Example
Computer Vision and Image Processing, [email protected]. 2024

Example Computer Vision and Image Processing, [email protected]. 2024

2. Find the smallest rectangle


1. Find the basic rectangle for n=18 (boundary) that fits the shape

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

5. Find the difference Shape No.


000310330130031303
6. Find the shape no.
3. Create grid 4. Find the nearest grid
Image Representation & Image Representation &
Description Description
Fourier Descriptor Fourier Descriptor
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


View a coordinate (x, y) as a complex number:
o This is a way of using the Fourier transform to analyze the
shape of a boundary. x = real part and y = imaginary part, then apply the
Fourier transform to a sequence of boundary points.
 The x -y coordinates of the boundary are treated as the
real and imaginary parts of a complex number. Let s(k) be a coordinate
s(k )  x (k )  jy ( k )
 Then the list of coordinates is Fourier transformed using of a boundary point k :
the DFT.
K 1
 The Fourier coefficients are called the Fourier 1
descriptors.
Fourier descriptor : a (u ) 
K
 s ( k )e
k 0
 2uk / K

 The basic shape of the region is determined by the first


several coefficients, which represent lower frequencies. Reconstruction formula
 Higher frequency terms provide information on the fine Boundary 1 K 1
detail of the boundary. points
s(k )  
K k 0
a (u )e 2uk / K

Image Representation & Image Representation &


Description Description
Fourier Descriptor
Examples of reconstruction from Fourier descriptors Fourier Descriptor
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Fourier descriptors are not directly insensitive to
P 1
1 geometric transformation, but the changes in these
sˆ(k ) 
K
 a (u )e 
k 0
2 uk / K

parameters can be related to simple transformations on the


descriptors by using the following properties:
P is the number of
Fourier coefficients Transformation Boundary Fourier Descriptor
used to reconstruct Identity  *
= C3  * =  * C3
the boundary
Rotation 

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

Computer Vision and Image Processing, [email protected]. 2024


K 1
n ( r )   ( ri  m) g ( ri ) The first moment = mean
n
1. Some simple regional descriptors (discussed above)
i 0 The second moment = variance - Area of the region
where K 1 - Length of the boundary (perimeter) of the region
m   ri g ( ri ) - Compactness
i 0 A( R )
C 2
Boundary P ( R)
segment 1D graph where A (R) and P (R) = area and perimeter of region R
Example: a circle is the most compact shape with C = 1/4p

1. Convert a boundary segment into 1D graph 2. Topological Descriptors


2. View a 1D graph as a PDF function 3. Texture
3. Compute the nth order moment of the graph 4. Moments of 2D Functions

Image Representation & Image Representation &


Description Description
Regional Descriptors: Examples
Topological
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


White pixels represent Used to describe holes and connected components of the
“light of the cities” region
Euler number (E):
A region with E CH
% of white pixels
Region no. compared to the two holes
total white pixels C = the number of connected
components
1 20.4% H = the number of holes
2 64.0%
3 4.9%
4 10.7%
A region with
three connected
components
Infrared image of America at night
Image Representation & Image Representation &
Description Description
Topological Topological: Example
E = -1
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Euler Formula Original image: After intensity
Infrared image Thresholding
Of Washington (1591
V Q  F  C  H  E D.C. area connected
components
with 39 holes)
E=0 V = the number of vertices Euler no. =
Q = the number of edges 1552
F = the number of faces
The largest
connected
area
(8479 Pixels) After thinning
(Hudson river)

E = -2

Image Representation & Image Representation &


Description Description
Texture Texture: Statistical Approaches
Purpose: to describe “texture” of the region, e.g., optical We can use statistical moments computed from an image histogram:
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


microscope images. K 1
Probability Density Functions: PDF
n ( z )   ( zi  m)n p( zi )
i 0 z = intensity
where K 1 p(z) = PDF or histogram of z
m   zi p( zi )
B C
i 0
A
Example: The 2nd moment = variance  measure “smoothness”
The 3rd moment  measure “skewness”
The 4th moment  measure “uniformity” (flatness)

Texture Mean Standard R Third Uniformity Entropy


deviation (normalized) moment
A Smooth 82.64 11.79 0.002 -0.105 0.026 5.434
Cholesterol Microprocessor B Coarse 143.56 74.63 0.079 -0.151 0.005 7.783
Superconductor
(smooth texture) (coarse texture) (regular texture) C Regular 99.72 33.73 0.017 0.750 0.013 6.674
Image Representation & Image Representation &
Description Description
Texture: Spectral (Fourier) Approaches Texture: Spectral (Fourier) Approaches
Concept: convert 2D spectrum into 1D graphs
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Original 2D Spectrum
Fourier image (Fourier Tr.)
Original FFT2D Divide into areas
coefficient
image +FFTSHIFT by angles
image

Divide into areas by radius Sum all pixels S(r) S(q)


in each area

R0
S ( )   Sr ( )
r 1
Another Another
 image S(q)
S ( r )   S ( r )
Sum all pixels in each area  0

Image Representation & Image Representation &


Description Description
Moments of Two-D Functions Invariant Moments of Two-D Functions
The moment of order p + q The normalized central moments of order p + q
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


 pq
m pq   x p y q f ( x, y ) x
m10
y
m01  pq  pq where   1
x y m00 m00 00 2
Invariant moments: independent of rotation, translation, scaling,
The central moments of order p + q
and reflection
 pq   ( x  x ) p ( y  y ) q f ( x, y ) 1  20  02 2  20  02 2  4112
x y
3  30  312 2  321  03 2 4  30  12 2  21  03 2
00  m00 01  10  0
11  m11  x m01  m11  ym10 12  m12  2 ym11  x m02  2 y m10 2

5  30  312 30  12  30  12 2  321  03 2  
20  m20  x m10 02  m02  ym01
321  03 21  03 3  12   21  03
2

2

30  m30  3x m20  2 x 2m10 30

21  m21  2 x m11  ym20  2 x m01


2
03  m03  3 ym02  2 y m01 2 
6  20  02  30  12 2  21  03 2  
411 30  12 21  03 
Image Representation & Image Representation &
Description Description
Invariant Moments of Two-D Functions: Example Invariant Original Half Size Mirrored Rotated 2o Rotated 45o
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


3. Mirrored (Log)
∅
1. Original image 2. Half size

6.249 6.226 6.919 6.253 6.318

∅
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

Image Representation & Image Representation &


Description Description
Use of Principal Components for Description Use of Principal Components for Description
Purpose: to reduce dimensionality of a vector image while Components transformation Let y  A (x  m x )
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


maintaining information as much as possible.
Where A is created from eigenvectors of Cx as follows
Row 1 contain the 1st eigenvector with the largest eigenvalue.
Let
Row 2 contain the 2nd eigenvector with the 2nd largest
x  [ x1 x2 ... xn ]T eigenvalue.….
Then we get 1 0 ... 0 
Mean:
1 K m y  E{y}  0 0  ... 0 
m x  E{x}  x k and Cy   1 
K k 1  ... ...
... ... 
C y  AC x A T
 
 0 ...... 1 
Covariance matrix
K
Then elements ofy  A ( x  m x ) are uncorrelated. The
1
C x  E{(x  m x )( x  m x ) } 
T

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

Computer Vision and Image Processing, [email protected]. 2024


Eigenvector and Eigenvalue from an airborne
Eigenvector and eigenvalue of Matrix C are defined as Scanner.

Let C be a matrix of size NxN and e be a vector of size Nx1.


Channel Wavelength band
If (microns)
Ce  e 1 0.40-0.44
2 0.62-0.66
3 0.66-0.72
Where l is a constant 4 0.80-1.00
5 1.00-1.40
6 2.00-2.60
We call e as an eigenvector and l as eigenvalue of C

Image Representation & Image Representation &


Description Description
Principal Components: Examples Principal Components: Examples
Computer Vision and Image Processing, [email protected]. 2024

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

Original image After components transform


Image Representation & Image Representation &
Description Description
Principal Components: Examples Relational Descriptors
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


An object Coded
structure
A simple
staircase
structure

Object rotated by using Sample


Eq. The net effect is to derivation for
align the object along rules
its eigen axes SaA,
Eigenvectors AbS, and
Ab

Image Representation & Image Representation &


Description Description
Relational Descriptors Relational Descriptors
A simple tree with root $ and frontier xy.
Computer Vision and Image Processing, [email protected]. 2024

Computer Vision and Image Processing, [email protected]. 2024


Abstracted
primitives.
Code a region Tree representation obtained by
Operations
boundary with using the relationship “inside of”
among primitives
directed line
segments
A set of specific
primitives.

Steps in building
a structure.
A simple composite region
[email protected]

Company
LOGO

You might also like