You are on page 1of 36

Lecture-4

Computer Vision
By : Dr. Shimaa Saber

1
Course Ethics
Agenda
1. Introduction to Feature Extraction

2. Shape-Based Methods

➢Chain Code

➢Geometric parameters

3
Feature Extraction Stage

4
Computer Vision System
Real world
 The results of segmentation
Sensor is a set of regions.
Digital image
Pre-processing  Regions have then to be
Better image represented and described.
Segmentation
Sub image/Regions  Our Goal: to describe the
regions based on chosen
Feature Extraction
representation “Compute
Feature Vector
numeric or symbolic
High-level processing information from the collected
data”
5 Decision Making
Feature Extraction
 Feature extraction is the process by which certain features of
interest within an image are detected and represented for
further processing.

 It is a critical step in most computer vision because it marks


the transition from pictorial to non-pictorial data
representation.

 Benefits:
➢ Easier to understand
➢ Require less memory, faster to be processed
➢ More “ready to be used” for the classification process.
6
Feature Extraction and Description
 Two types of features.
➢ Global Features: extract characteristics that represent the
overall structure of image. These features summarize
information across the entire image.
➢ Local Features : focus on analyzing specific regions or
small neighborhoods within an image.

 Properties of “Good” descriptor:


➢ Description should be invariant to “ Rotation, Scale ”
➢ A descriptor should only contain information about what
makes an object unique
➢ Useful for matching
7
Feature Extraction and Description
Features extraction methods

Shape-based Texture-based Color-based


methods methods methods
GLCM
Chain Code Histogram
LBP
Geometric parameters correlogram
Harries
Statistical Moments
SIFT
HOG

8
Shape Features
Chain Code

9
Chain Code
What are the Chain codes?
represent an object boundary by a connected sequence of straight line
segments of specified length and direction.

Why do we focus on a
boundary?
The boundary is a good
representation of an object’s 4-directional 8-directional
shape and also requires a few chain code chain code
memory.
Chain Code
 Chain code is a lossless compression algorithm for
monochrome images “binary images”.
 Chain code is representing the boundary of a binary
object, Instead of storing the positions of all the
boundary pixels, we select a starting pixel and store
only its coordinate

4- directional 8- directional

11
8-Direction Chain Code

8- directional

 Chain Code: 0 7 0 6 6 7 6 4 4 4 3 3 2 2 1
12
4-direction Chain Code

4- directional

 Chain Code: 0 3 0 0 3 3 3 0 3 2 2 2 1 2 1 2 1 1 0 1
13
Chain Code

4- directional

14 8- directional
Chain Code

Object boundary Boundary vertices


15
(resampling)
Chain Code

 Chain Code: 0 7 6 6 6 6 6 4 5 3 3 2 1 2 1 2
16
Chain Code

 Chain Code:0 0 3 3 3 3 3 3 2 2 3 2 1 1 2 1 1 0 1 1 0 1
17
Chain Code
Chain code representation is conceptually has the following two
problems
➢ Dependent on the starting point
➢ Dependent on the orientation

2 6

4
Code = 0642
Code = 7531
18 Code = 6420
Chain Code
We need to achieve invariance to the starting point.
➢ Solution: Normalized codes
treat a chain code as a circular sequence and redefine the starting
point so that the resulting sequence of numbers forms an
integer of minimum magnitude.

0 All codes
0642
2 6 6420
6206
4 2064
Code = 3434054670077000112
19 Min= 0001123434054670077
Chain Code
We need to achieve invariance to the starting point.
➢ Solution: Differential codes
0

2 6

4
Code = 0642 Code = 7531
Code 1 Code 2
0-2(mod8) = 6 7-1(mod8) = 6 Differential code S1= 6666
6-0(mod8) = 6 5-2(mod8) = 6
4-6(mod8) = 6 3-5(mod8) = 6 Differential code S2 = 6666
2-4(mod8) = 6 1-3(mod8) = 6
20
Shape Numbers
 Shape number is the smallest magnitude of the first
difference of a chain code representation.

2 0

3
Code 1= 33221010 Code 2= 33212100
Diff 1= 30303313 Diff 2= 30331330
min 1= 03033133 min 2= 03033133

21
Chain Code & Shape Number

1. Original 2. Find the smallest


boundary 3. Create a grid 4. Find the nearest
rectangle that fits the Grid.
shape

 Chain Code = 121110110330333232


 Diff = 31300310331300313
 Shape number = 00310331300313313
22
Shape Features
Geometric parameters: Perimeter

23
Perimeter
 A region can be described by considering scalar
measures based on its geometric properties.

 Perimeter is a simple property of the region.

 Perimeter is the length of region’s boundary (The


number of pixels in the boundary of the shape).

24
Perimeter
𝑃 = ෍ ( 𝑋𝑖 − 𝑋𝑖−1 )2 + (𝑦𝑖 − 𝑦𝑖−1 )2
𝑖
Where 𝑋𝑖 and 𝑦𝑖 represent the coordinates of the ith pixel

 Another Way to calculate perimeter by obtaining from the


chain code of the object boundary.

𝑃 = 𝑛𝑒 + 2 𝑛𝑜
where 𝑛𝑒 is the number of even and 𝑛𝑜 is number of odd chain
code steps of 8-direction

25
0,1

Perimeter 1,0 1,2

2,1

𝑃 = ෍ ( 𝑋𝑖 − 𝑋𝑖−1 )2 + (𝑦𝑖 − 𝑦𝑖−1 )2


𝑖
P = ( 0 − 1)2 + (1 − 0)2 + ( 1 − 0)2 + (2 − 1)2 + ( 2 − 1)2 + (1 − 2)2 +
( 1 − 2)2 + (0 − 1)2 = 2 + 2 + 2 + 2 = 4 2 = 5.65

𝑃 = 𝑛𝑒 + 2 𝑛𝑜
Chain Code = 7531
𝑛𝑒 = 0 𝑛𝑜 = 4
P = 0+ 2 ∗ 4 = 4 2 = 5.65
26
Shape Features
Geometric parameters: Area

27
Area
 A region can be described by considering scalar
measures based on its geometric properties.

 The simplest property is given by its size or area.

 It is the number of pixels contained within its boundary


(The number of pixels in the shape).

28
Area
 To compute the Area of an object or shape 𝐴 (𝑆), use the
following eq:

 𝐼(𝑥, 𝑦) = 1 if the pixel is within a shape, 𝐼(𝑥, 𝑦) ∈ S, and 0


otherwise.

29
A(S) = 0 + 0 + 0 + 0 + 1 + 1 + 1 + 0+
1 + 1+ 1 + 1 + 1 + 1 + 1 + 0

A(S) = 10
30
Shape Features
Geometric parameters: Compactness

31
Compactness
 It is one of the geometric properties.

 Compactness is defined as the ratio of the area of an


object to the area of a circle with the same perimeter.

32
Compactness
0,1
Area (A) =5 1,0 1,2

2,1
Perimeter = 4 2

4𝜋 ∗5
Compactness = 2 = 0.061
4 2

33
Applications used Chain Code
 Reading Car Plates for Radar Application

34
Summary
1. Introduction to Feature Extraction
2. Chain Code
3. Shape number
4. Area
5. Perimeter
6. compactness

35
36

You might also like