Ch4 Part2 Feature ExtractionMatching
Ch4 Part2 Feature ExtractionMatching
Computer Vision
Course
School of Information and
Communication Technology
Computer Vision
Chapter 4: Feature detection and Image matching
(Part 2: Feature extraction and matching)
Computer Vision Group
School of Information and Communications Technology
1
20/02/2024
Plan
• Edge detection
• General approach
• Image gradient, Canny detector, Laplacian
• Line detection from contour points (Hough transform)
• Feature Extraction
• Global features
• Local features
• Image matching and Applications
A ball?
An official match ball
for Qatar 2022?
Matrix of integers:
- Redundant information Decision model
- Many of discret numbers
2
20/02/2024
https://www.theguardian.com/
Good feature?
• Identifiable
• easily tracked and compared
• Consistent across different scales, lighting conditions, and
viewing angles
• Still visible in noisy images or when only part of an object
is visible
3
20/02/2024
• Local feature:
• the local features describe the image patches (key points in the image)
of an object
• represents the texture/color in an image patch
• Examples: SIFT, SURF, LBP, BRISK, MSER and FREAK, …
Feature extraction
• Global features
• Color / Shape / Texture
• Local features
4
20/02/2024
Global features?
Types of features
10
5
20/02/2024
Color features
• Histogram
256 bins intensity histogram 16 bins intensity histogram
11
Distance / Similarity
N
d L1 (H, G) = å hi - g i
i =1
• Histogram intersection
∑! min( ℎ! , 𝑔! )
∩ (H,G) =
∑! 𝑔!
12
6
20/02/2024
Advantages of histogram
13
Some inconveniences
14
7
20/02/2024
Some inconveniences
I3
I1
I2
15
Texture features
16
8
20/02/2024
Texture features
• Co-occurence matrices
• Searching patterns
• Frequential analysis
• Gabor filter
• …
• The most difficult is to find a good representation
(good parameters) for each texture
17
Texture features
Texture features
Statistical
Spectral
General statistics parameters
Haralick’s co-occurrence matrices PWT
Tamura features Model-based
TWT
DCT, DST, DHT
Markov random fields
Complex wavelets
Fractals
Gabor filters
Geometrical
ICA filters
Voronoi tesselation features
Structural methods
18
9
20/02/2024
19
$ &'
µ= $ 𝑖 .𝑃 𝑖 Mean = image brightness
!"#
$ &'
Variance measures the deviation of gray
𝜎( = $ (𝑖 − 𝜇)(. 𝑃 𝑖 levels from the Mean
!"#
1 $ &'
𝑠 = *$ (𝑖 − 𝜇)*. 𝑃 𝑖 Skewness is a measure of the degree of
𝜎 !"# histogram asymmetry around the Mean
1 $ &'
Kurtosis is a measure of the
𝑘= ) $ (𝑖 − 𝜇)). 𝑃 𝑖 − 3 histogram sharpness
𝜎 !"#
$ &'
Entropy is a measure of
𝐻 = −$ 𝑃 𝑖 log 𝑃(𝑖) randomness
!"#
$ &' (
𝐸= $ 𝑃 𝑖 Energy measures the smoothness
!"#
CV Group – School of Information and Communication and Technology 20
20
10
20/02/2024
21
22
11
20/02/2024
23
card ({ p1 , p2 I ( p1 ) = ci , I ( p2 ) = c j , N d , b ( p1 , p2 ) = true})
CM d , b (ci , c j ) =
card ({ p1, p 2 N d , b ( p1 , p2 ) = true})
24
12
20/02/2024
Cj: grayscale of p2
1 2 3 4
1 4 4 3
Ci: grayscale of p1
1 ? ? ? ?
4 2 3 2
2 ? ? ? ?
1 2 1 4
3 ? ? ? ?
1 2 2 3
4 ? ? ? ?
Image
Matrix for distance=1 and direction=0°
p1
p2
We loop over the image and for each pair of pixels following the given
distance and orientation, we increment the co-occurence matrix
25
1 2 3 4
1 4 4 3
1 0 0 0 1
4 2 3 2
2 0 0 0 0
1 2 1 4
3 0 0 0 0
1 2 2 3
4 0 0 0 0
Image
Matrix for distance=1 and
direction=0°
26
13
20/02/2024
1 2 3 4
1 4 4 3
1 0 0 0 1
4 2 3 2
2 0 0 0 0
1 2 1 4
3 0 0 0 0
1 2 2 3
4 0 0 0 1
Image
Matrix for distance=1 and
direction=0°
27
1 2 3 4 1 2 3 4
1 4 4 3
1 0 2 0 2 1 0 2 1 0
4 2 3 2
2 1 1 2 0 2 1 1 0 0
1 2 1 4
3 0 1 0 0 3 0 0 0 1
1 2 2 3
4 0 1 1 1 4 0 2 1 0
Image
Matrix for distance=1 Matrix for distance=1
and direction=0° and direction=45°
29
14
20/02/2024
30
31
15
20/02/2024
Invariances
• Scaling?
• Multi-resolutions
32
Source : William Robson Schwartz et al. Evaluation of Feature Descriptors for Texture Classification – 2012 JEI
CV Group – School of Information and Communication and Technology 33
33
16
20/02/2024
Shape features
• Contour-based features:
• Chain coding, polygone approximation, geometric
parameters, angular profile, surface, perimeter, …
• Region based:
• Invariant moments, …
34
Shape features
Shape features
Boundary-based methods
Region-based methods
Gometrical Signatures
Global
Perimeter Centroid Distance Geometrical
Eccentricity Complex Coordinates Moment invariants
Curvature Curvature signature Area Zernike moments
Axes directionality Turning Angle Compactness Pseudo Zernike moments
Euler number
Grid method
Others Signature descriptors Decompasition
Chain codes Fourier Descriptors Triangulation
UNL-Fourier Medial Axis Transform
NFD (Skeleton Transform)
Wavelet Descriptors
B-Splines
35
17
20/02/2024
37
• Moment
Invariant to
translation
38
18
20/02/2024
invariant to
translation,
scale, and
rotation, and
reflection
Change for
image
reflection
39
https://www.learnopencv.com/wp-content/uploads/2018/12/HuMoments-Shape-Matching.png
40
19
20/02/2024
Shape Context
https://www2.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html
41
Examples: HOG
Source: LearnOpenCV.com
42
20
20/02/2024
Examples: PHOG
PHOG:
Pyramid Histogram of Oriented Gradients
Source:http://www.robots.ox.ac.uk/~vgg/research/caltech/phog.html
43
Feature extraction
• Global features
• Local features
• Interest point detector
• Local descriptor
44
21
20/02/2024
45
Image matching
by swashford
by Diva Sian
by scgbt
Slide credit: Steve Seitz
46
22
20/02/2024
Harder Still?
47
NASA Mars Rover images with SIFT feature matches Slide credit: Steve Seitz
(Figure by Noah Snavely)
CV Group – School of Information and Communication and Technology 48
48
23
20/02/2024
• Articulation
d dq
φ
φ
θq
θ
• Intra-category variations
Source: CS131 - Juan Carlos Niebles and Ranjay Krishna
CV Group – School of Information and Communication and Technology 49
49
• Partial search
• Object recognition/ detection
D. Lowe 2002
50
Lowe 2002
24
20/02/2024
• Panorama:
• Detect feature points in both images
• Find corresponding pairs
52
• Panorama:
• Detect feature points in both images
• Find corresponding pairs
• Use these pairs to align images
53
25
20/02/2024
• Image matching:
55
Dividing into
patches with Keypoint detection
regular grid
Image segmentation
57
26
20/02/2024
Common Requirements
• Problem 1:
• Detect the same point independently in both images
No chance to match!
58
Requirements- Summary
62
27
20/02/2024
Main questions
63
Feature extraction
• Global features
• Local features
• Interest point detector
• Local descriptor
• Matching
64
28
20/02/2024
65
Keypoint Localization
• Goals:
• Repeatable detection
• Precise localization
• Interesting content
Þ Look for two-dimensional signal changes
67
29
20/02/2024
Finding Corners
• Key property:
• In the region around a corner, image gradient has two or
more dominant directions
• Corners are repeatable and distinctive
C.Harris and M.Stephens. "A Combined Corner and Edge Detector.“ Proceedings of the 4th Alvey
Vision Conference, 1988.
Slide credit: Svetlana Lazebnik
68
69
30
20/02/2024
Large
Corner
Large
Small
Edge
Large
Small
Nothing
Small
70
E (u , v) = å w( x, y ) [ I ( x + u , y + v) - I ( x, y ) ]
2
x, y
or
Window function w(x,y) =
71
31
20/02/2024
E (u, v) = å w( x, y) [ I ( x + u, y + v) - I ( x, y) ]
2
x, y
I(x, y)
E(u, v)
E(0,0)
w(x, y)
CV Group – School of Information and Communication and Technology 72
72
E (u, v) = å w( x, y) [ I ( x + u, y + v) - I ( x, y) ]
2
x, y
I(x, y)
E(u, v)
E(3,2)
w(x, y)
73
32
20/02/2024
éu ù
E (u, v) » [u v] M ê ú
ëv û
where M is a 2´2 matrix computed from image derivatives:
é I2 IxI y ù
M = å w( x, y) ê x
Gradient with respect to x,
ú times gradient with respect to y
x, y êë I x I y I y2 úû
M
Slide credit: Rick Szeliski
81
é å I x2 åI I x y
ù él1 0 ù
M =ê ú=ê ú
ëêå I x I y åI ûú ë 0 l2 û
2
y
• This means:
• Dominant gradient directions align with x or y axis
• If either λ is close to 0, then this is not a corner, so look for
locations where both are large.
83
33
20/02/2024
General case
Direction of the
fastest change
Direction of the
slowest change
(lmax)-1/2
(lmin)-1/2
84
l2 “Edge”
l2 >> l1 “Corner”
l1 and l2 are large, l1 ~ l2 ;
E increases in all directions
85
34
20/02/2024
• Fast approximation
• Avoid computing the
eigenvalues “Flat” “Edge”
• α: constant region θ<0
(0.04 to 0.06) l1
86
é I2 IxI y ù
M = åê x ú
1 in window, 0 outside êIx I y
x, y ë I y2 ûú
• Problem: not rotation invariant
87
35
20/02/2024
3. Gaussian
filter g(sI)
• Compute corner response g(Ix2) g(Iy2) g(IxIy)
C.Harris and M.Stephens. “A Combined Corner and Edge Detector.” Proceedings of the 4th Alvey
Vision Conference: pages 147—151, 1988. Slide credit: Krystian Mikolajczyk
88
89
36
20/02/2024
90
91
37
20/02/2024
92
93
38
20/02/2024
94
• Translation invariance
• Rotation invariance?
• Scale invariance?
95
39
20/02/2024
96
Invariance
99
40
20/02/2024
• Solution:
• Design a function on the region, which is “scale invariant” (the
same for corresponding regions, even if they are at different scales)
f Image 1 f Image 2
scale = 1/2
100
• Common approach:
f Image 1 f Image 2
scale = 1/2
101
41
20/02/2024
Same operator responses if the patch contains the same image up to scale
factor.
K. Grauman, B. Leibe
102
CV Group – School of Information and Communication and Technology 102
102
Example
103
42
20/02/2024
Example
105
Example
106
43
20/02/2024
Example
107
f f f
Good !
bad bad
region size region size region size
108
44
20/02/2024
DoG = G( x, y, ks ) - G( x, y, s )
(Difference of Gaussians)
where Gaussian
x2 + y 2
-
G ( x, y , s ) = 1
2ps
e 2s 2
Note: both kernels are invariant
to scale and rotation
109
110
45
20/02/2024
Characteristic scale
characteristic scale
T. Lindeberg (1998). "Feature detection with automatic scale selection." IJCV 30 (2): pp 77--116.
Source: Lana Lazebnik
CV Group – School of Information and Communication and Technology 111
111
Laplacian-of-Gaussian (LoG)
• Interest points:
Local maxima in scale s5
space of LoG
s4
Lxx (s ) + Lyy (s ) s3
s2
Þ List of
s (x, y, σ)
112
46
20/02/2024
Alternative approach
116
Alternative approach
- =
117
47
20/02/2024
Find maxima
…
…
ks 2ks
- =
s
- ks Þ List of
= (x, y, s)
- =
s
Input image
118
Harris-Laplacian
• Harris-Laplacian1
Find local maximum of: scale
¬ Laplacian ®
1
K.Mikolajczyk, C.Schmid. “Indexing Based on Scale Invariant Interest Points”. ICCV 2001
2
D.Lowe. “Distinctive Image Features from Scale-Invariant Keypoints”. IJCV 2004
119
48
20/02/2024
• Harris-Laplacian1
Find local maximum of: scale
¬ Laplacian ®
• Harris corner detector in space (image coordinates)
• Laplacian in scale
y
¬ Harris ® x
¬ DoG ®
Find local maximum of:
- Difference of Gaussians in space y
and scale
¬ DoG ® x
1 K.Mikolajczyk, C.Schmid. “Indexing Based on Scale Invariant Interest Points”. ICCV 2001
2 D.Lowe. “Distinctive Image Features from Scale-Invariant Keypoints”. IJCV 2004
120
• DoG at multi-octaves
• Extrema detection in scale space
• Keypoint location
• Interpolation
• Removing instable points
• Orientation Assignment
121
49
20/02/2024
• DoG at multi-octaves
( )
G k 2s * I
G(ks )* I
D(s ) º (G(ks ) - G(s ))* I
G(s )* I
122
( )
D k 2s
D(ks )
D(s )
123
50
20/02/2024
• Orientation assignment
• Create histogram of local gradient
directions at selected scale
• Assign orientation at peak of smoothed
histogram
• Each key specifies stable 2D
coordinates
(x, y, scale,orientation)
124
125
51
20/02/2024
126
Repeatability rate:
# correspondences
# possible correspondences
K.Mikolajczyk, C.Schmid. “Indexing Based on Scale Invariant Interest Points”. ICCV 2001
127
52
20/02/2024
• Others…
128
Feature extraction
• Global features
• Local features
• Interest point detector
• Local descriptor
• Matching
129
53
20/02/2024
Local Descriptor
• Invariant
• Geometric transformations: rotation, translation, scaling,..
• Camera view change
• Illiminution
• Exemples
• SIFT, SURF(Speeded Up Robust Features), PCA-SIFT, …
• LBP, BRISK, MSER and FREAK, …
130
Following slides credit: CVPR 2003 Tutorial on Recognition and Matching Based on Local Invariant Features David Lowe
131
54
20/02/2024
132
133
55
20/02/2024
134
0 2p
135
56
20/02/2024
136
SIFT
Steve Seitz
Steve
CV Group – School of Information and Communication and Technology Seitz 142
142
57
20/02/2024
143
David G. Lowe, "Distinctive image features from scale-invariant keypoints," IJCV, 60, 2 (2004), pp. 91-110
144
58
20/02/2024
145
Distinctiveness of features
• Vary size of database of features, with 30 degree affine change, 2% image
noise
• Measure % correct for single nearest neighbor match
146
59
20/02/2024
147
148
60
20/02/2024
Feature extraction
• Global features
• Local features
• Interest point detector
• Local descriptor
• Matching
149
Feature matching
2. Test all the features in I2, find the one with min distance
OpenCV:
- Brute force matching
- Flann Matching: Fast Library for Approximate Nearest Neighbors
[Muja and Lowe, 2009]
Marius Muja and David G Lowe. Fast approximate nearest neighbors with automatic algorithm configuration. In VISAPP (1),
pages 331–340, 2009
150
61
20/02/2024
Feature matching
151
Feature matching
f1 f2
I1 I2
CV Group – School of Information and Communication and Technology 152
152
62
20/02/2024
Feature matching
f1 f2' f2
153
I1 I2
CV Group – School of Information and Communication and Technology
153
David G. Lowe, "Distinctive image features from scale-invariant keypoints," IJCV, 60, 2 (2004), pp. 91-110
154
63
20/02/2024
Feature matching
155
Feature matching
• Six variables
• Each point give two equations
• è at least three points
• Least squares
156
64
20/02/2024
50
75
200
157
True/false positives
50
true match
75
200
false match
feature distance
158
65
20/02/2024
Image matching
159
Voting strategy
Selected region
for query The similarity between 2
images is based on the
number of matches
160
66
20/02/2024
Optimization problem
• Transportation problem
f ij ³ 0
åfi
ij £ w j , å f ij £ wi
j
åå f ´ d (r , r '
*
)
åå f ij = min(å wi , å w j )
d EMD (I , I ) =i j
ij i j
åå f
i j i j 1 2 *
ij
i j
http://vellum.cz/~mikc/oss-projects/CarRecognition/doc/dp/node29.html
CV Group – School of Information and Communication and Technology 161
161
Bag-of-words
162
67
20/02/2024
Visual Vocabulary …
163
1. Extract features
2. Learn “visual vocabulary”
3. Quantize features using visual vocabulary
4. Represent images by frequencies of
“visual words”
164
68
20/02/2024
Applications
165
Object detection/recognition/search
Lowe 2002
Rothganger et al. 2003
166
69
20/02/2024
Object detection/recognition
David Low, Distinctive Image Features from Scale-Invariant Keypoints, IJCV 2004
167
168
70
20/02/2024
169
Automatic mosaicing
http://www.cs.ubc.ca/~mbrown/autostitch/autostitch.html
170
71
20/02/2024
171
172
72
20/02/2024
Source. http://www-rocq.inria.fr/imedia
173
Tập đặc
20 ảnh/nhóm trưng
SIFT
5 ảnh/nhóm
~80 ảnh/nhóm
~60 ảnh/nhóm
CSDL mô tả đặc
trưng ảnh SIFT
dưới dạng các
vector trọng số
Tập ảnh test
Source: ĐATN – Phạm Xuân Trường K52 - BK
174
73
20/02/2024
175
176
74
20/02/2024
References
177
THANK YOU !
178
75