Slide 1

Slide 1 text

Master Mathematical Analysis and Applications Course M1 - S2 Computer vision Key-points extraction, description, and matching Week 6-8 Mohammed Hachama [email protected] http://hachama.github.io/home/ University of Khemis Miliana -2020-

Slide 2

Slide 2 text

Keypoints Plan 1. Keypoints extraction, description and matching Computer vision -Key-points extraction, description, and matching- (Week 6-8) (2/13) M. Hachama ([email protected])

Slide 3

Slide 3 text

Keypoints Keypoints Corners Blobs SIFT Keypoints Computer vision -Key-points extraction, description, and matching- (Week 6-8) (3/13) M. Hachama ([email protected])

Slide 4

Slide 4 text

Keypoints Keypoints Corners Blobs SIFT What is a good Keypoint ? Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 5

Slide 5 text

Keypoints Keypoints Corners Blobs SIFT What is a good Keypoint ? • Repeatability and stability • The same keypoint can be found in several images despite geometric and photometric transformations. These points usually don’t keep moving around in the image. This helps tracking. • Saliency (Uniquely identifiable) • Each keypoint is distinctive • Compactness and efficiency • Many fewer keypoints than image pixels • Locality • A keypoint occupies a relatively small area of the image ; robust to clutter and occlusion Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 6

Slide 6 text

Keypoints Keypoints Corners Blobs SIFT Applications Panorama stitching • Step 1 : extract keypoints • Step 2 : match keypoint features • Step 3 : align images Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 7

Slide 7 text

Keypoints Keypoints Corners Blobs SIFT Applications Panorama stitching • Step 1 : extract keypoints • Step 2 : match keypoint features • Step 3 : align images Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 8

Slide 8 text

Keypoints Keypoints Corners Blobs SIFT Applications Panorama stitching • Step 1 : extract keypoints • Step 2 : match keypoint features • Step 3 : align images Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 9

Slide 9 text

Keypoints Keypoints Corners Blobs SIFT Applications Panorama stitching • Step 1 : extract keypoints • Step 2 : match keypoint features • Step 3 : align images Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 10

Slide 10 text

Keypoints Keypoints Corners Blobs SIFT Applications Matching Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 11

Slide 11 text

Keypoints Keypoints Corners Blobs SIFT Applications Matching Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 12

Slide 12 text

Keypoints Keypoints Corners Blobs SIFT Applications Matching Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 13

Slide 13 text

Keypoints Keypoints Corners Blobs SIFT Applications 3D reconstruction : Structure from motion Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 14

Slide 14 text

Keypoints Keypoints Corners Blobs SIFT Applications Calibration : estimating “fundamental matrix” that corresponds two views Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 15

Slide 15 text

Keypoints Keypoints Corners Blobs SIFT Applications • Image alignment • Motion tracking • Robot navigation • Indexing and database retrieval • Object recognition • 3D reconstruction Computer vision -Key-points extraction, description, and matching- (Week 6-8) (4/13) M. Hachama ([email protected])

Slide 16

Slide 16 text

Keypoints Keypoints Corners Blobs SIFT Corner Detection Computer vision -Key-points extraction, description, and matching- (Week 6-8) (5/13) M. Hachama ([email protected])

Slide 17

Slide 17 text

Keypoints Keypoints Corners Blobs SIFT Keypoints : Corners • Aperture Problem Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 18

Slide 18 text

Keypoints Keypoints Corners Blobs SIFT Corner Detection • Based on boundary extraction • First step edge detection • Curvature analysis of edges • Based on brightness of images • Usually image derivatives • Popular technique : detector Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 19

Slide 19 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Basic Idea • We should easily recognize the point by looking through a small window • Shifting a window in any direction should give a large change in intensity Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 20

Slide 20 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Mathematics • Change in appearance of window W for the shift [u, v] : E(u, v) = (x,y)∈W [I(x + u, y + v) − I(x, y)]2 • First-order Taylor approximation I(x + u, y + v) ≈ I(x, y) + Ix (x, y)u + Iy (x, y)v • Let’s plug this into E(u, v) E(u, v) ≈ (x,y)∈W [I(x, y) + Ix (x, y)u + Iy (x, y)v − I(x, y)]2 ≈ (x,y)∈W I2 x u2 + 2Ix Iy uv + I2 y v2 Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 21

Slide 21 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Mathematics • Change in appearance of window W for the shift [u, v] : E(u, v) ≈ u v x,y I2 x x,y Ix Iy x,y Ix Iy x,y I2 y u v • The surface E(u,v) is locally approximated by a quadratic form. • In which directions does it have the smallest/greatest change ? Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 22

Slide 22 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Harris region • Matrix and eigenvalues M = x,y I2 x x,y Ix Iy x,y Ix Iy x,y I2 y • Analysis of λ1 and λ2 , the eigenvalues of M Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 23

Slide 23 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Criteria • Harris criterion R = det(M) − k(trace(M))2 • |R| is small : λ1 and λ2 are small → the region is flat. • R < 0 : λ1 >> λ2 or vice versa → the region is edge. • R is large : λ1 and λ2 are large and λ1 ∼ λ2, → corner. • Shi-Tomasi criterion : threshold R = min(λ1 , λ2 ) • Experimentally, this score criteria was much better. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 24

Slide 24 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Algorithm • Compute horizontal and vertical derivatives of image Ix and Iy • Compute three images corresponding to three terms in matrix M. Convolve these three images with a Gaussian filter. • Compute R • Find local maxima by thresholding R and applying non maximum suppression. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 25

Slide 25 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Example Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 26

Slide 26 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Example Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 27

Slide 27 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Example Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 28

Slide 28 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Example Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 29

Slide 29 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Invariance and covariance • Invariance : when the image is transformed, corner locations doe not change. • covariance : when the image is transformed, corner locations get transformed with the same function. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 30

Slide 30 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Invariance and covariance • Corner location is covariant w.r.t. translation Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 31

Slide 31 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Invariance and covariance • Corner location is covariant w.r.t. rotation Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 32

Slide 32 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Invariance and covariance • Corner location is not covariant to scaling ! Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 33

Slide 33 text

Keypoints Keypoints Corners Blobs SIFT Harris Corner Detector Invariance and covariance • Affine intensity change : J = aI + b • Only derivatives are used : invariance to intensity shift J = I + b • Intensity scaling : J = aI Corner location is not covariant to scaling ! Computer vision -Key-points extraction, description, and matching- (Week 6-8) (6/13) M. Hachama ([email protected])

Slide 34

Slide 34 text

Keypoints Keypoints Corners Blobs SIFT Blob detection Computer vision -Key-points extraction, description, and matching- (Week 6-8) (7/13) M. Hachama ([email protected])

Slide 35

Slide 35 text

Keypoints Keypoints Corners Blobs SIFT Simple blob detection • A Blob is a group of connected pixels in an image that share some common property (E.g grayscale value). Computer vision -Key-points extraction, description, and matching- (Week 6-8) (8/13) M. Hachama ([email protected])

Slide 36

Slide 36 text

Keypoints Keypoints Corners Blobs SIFT Simple blob detection • Algorithm 1 Thresholding : Convert the source images to several binary images by thresholding the source image with thresholds : minThreshold : thresholdStep : maxThreshold 2 Grouping : Extract connected components from every binary image and calculate their centers. 3 Merging : Blobs whose centers are located closer than minDistBetweenBlobs are merged. 4 Center and Radius Calculation : The centers and radii of the new merged blobs are computed and returned. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (8/13) M. Hachama ([email protected])

Slide 37

Slide 37 text

Keypoints Keypoints Corners Blobs SIFT Simple blob detection • Results Computer vision -Key-points extraction, description, and matching- (Week 6-8) (8/13) M. Hachama ([email protected])

Slide 38

Slide 38 text

Keypoints Keypoints Corners Blobs SIFT Blob detection • Blobs are bright on dark or dark on bright regions in an image. • Blob = superposition of two ripples Computer vision -Key-points extraction, description, and matching- (Week 6-8) (9/13) M. Hachama ([email protected])

Slide 39

Slide 39 text

Keypoints Keypoints Corners Blobs SIFT Blob detection • Convolution of a blob signal with a Laplacian filter σ = 1 • Matching between the blob size and the Laplacian variance σ2. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (9/13) M. Hachama ([email protected])

Slide 40

Slide 40 text

Keypoints Keypoints Corners Blobs SIFT Blob detection • Blobs with different scales Computer vision -Key-points extraction, description, and matching- (Week 6-8) (9/13) M. Hachama ([email protected])

Slide 41

Slide 41 text

Keypoints Keypoints Corners Blobs SIFT LoG detector Expression • ”Scale normalized”-Laplacian of the Gaussian (LoG) L(x, y; σ) = σ2∇2g(x, y, σ) ∗ f (x, y), g(x, y, σ) = 1 2πσ2 e−x2+y2 2σ2 • σ2 is a scale normalization ; without, lim σ→+∞ L(x, y; σ) = 0 • Strong positive responses for dark blobs (maximum response for σ = r/ √ 2). • Strong negative responses for bright blobs of similar size. • For a given blob, choose the right scale for the right blob size. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (9/13) M. Hachama ([email protected])

Slide 42

Slide 42 text

Keypoints Keypoints Corners Blobs SIFT LoG detector Effect of Scale normalization Computer vision -Key-points extraction, description, and matching- (Week 6-8) (9/13) M. Hachama ([email protected])

Slide 43

Slide 43 text

Keypoints Keypoints Corners Blobs SIFT LoG detector Scale selection 1 • Convolve the input with scale-normalized LoG at several scales. • Find local maxima of squared Laplacian response in scale-space • Select (x, y, σ) that maximizes NormalizedLoG(x, y, σ). 1. T. Lindeberg. Feature detection with automatic scale selection. IJCV, 1998. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (9/13) M. Hachama ([email protected])

Slide 44

Slide 44 text

Keypoints Keypoints Corners Blobs SIFT Harris-Laplace Detector 2 • Multiscale Harris corner detection : σn = snσ0 . 2. K.Mikolajczyk, C.Shmitd ”Indexing Based on Scale invariant Interest Points”, ICCV 2001. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (10/13) M. Hachama ([email protected])

Slide 45

Slide 45 text

Keypoints Keypoints Corners Blobs SIFT Harris-Laplace Detector 2 • Scale selection based on Laplacian 2. K.Mikolajczyk, C.Shmitd ”Indexing Based on Scale invariant Interest Points”, ICCV 2001. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (10/13) M. Hachama ([email protected])

Slide 46

Slide 46 text

Keypoints Keypoints Corners Blobs SIFT SIFT Computer vision -Key-points extraction, description, and matching- (Week 6-8) (11/13) M. Hachama ([email protected])

Slide 47

Slide 47 text

Keypoints Keypoints Corners Blobs SIFT Basic idea • In the Scale-space, select (x, y, σ) that maximizes DoG(x, y, σ) (approx. of approximation of LoG) in all three dimensions. • Use of an efficient implementation. • Keypoints description : Definition of a feature vector for each keypoint. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (12/13) M. Hachama ([email protected])

Slide 48

Slide 48 text

Keypoints Keypoints Corners Blobs SIFT Algorithm 1 The scale space. 2 LoG approximations : DoG. 3 Finding keypoints. 4 Getting rid of low contrast keypoints. 5 Keypoint orientations. 6 Generating a feature. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 49

Slide 49 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 1. Scale space : repeating generating blurred half-sized images. • Images of the same octave have same size. • Each octave has 5 images obtained by increasing the blur. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 50

Slide 50 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 1. Scale space : repeating generating blurred half-sized images. • Image size reduction • Reason 1 : when σ increases, the kernel size needed for precise calculations increases, and so do the calculation time. We reduce the image size instead of increasing σ. • Reason 2 : After the convolution with the Gauss kernel, the higher frequencies in the image spectrum are almost erased - there is no gain in keeping a higher resolution Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 51

Slide 51 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 2. LoG approximations of the Laplacian with a difference of Gaussians DoG = G(x, y, kσ) − G(x, y, σ) ≈ (k − 1)σ2∆G(x, y) • Typical values : σ = 1.6, k = √ 2. • DoG already incorporate the σ2 normalization. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 52

Slide 52 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 2. LoG approximations of the Laplacian with a difference of Gaussians Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 53

Slide 53 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 3. Finding keypoints : For each octave, iterate over the pixels. X is marked as a ”key point” if its DoG is the greatest or least of all 26 neighbors. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 54

Slide 54 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 4. Getting rid of low contrast keypoints • Removing low contrast features in the DoG image. • Removing edges : use the Harris corner detector. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 55

Slide 55 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 5. Keypoint orientations • To assign a unique orientation to circular image windows : • Create histogram of local gradient directions in the patch • Assign canonical orientation at peak of smoothed histogram • Any later calculations are done relative to this orientation. This ensures rotation invariance. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 56

Slide 56 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 6. Generating a feature vector for the keypoint. • A 16x16 window around the keypoint. This 16x16 window is broken into sixteen 4x4 windows. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 57

Slide 57 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 6. Generating a feature vector for the keypoint. • Within each 4x4 window, gradient magnitudes and orientations are calculated. These orientations are put into an 8 bin histogram. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])

Slide 58

Slide 58 text

Keypoints Keypoints Corners Blobs SIFT Algorithm • 6. Generating a feature vector for the keypoint. • Form weighted histogram (8 bin) for 4x4 regions • Weight by magnitude and spatial Gaussian • Concatenate 16 histograms in one long vector of 128 dimensions. Computer vision -Key-points extraction, description, and matching- (Week 6-8) (13/13) M. Hachama ([email protected])