I = imread(’data/test.png’) ;
I = double(rgb2gray(I)/256) ;
[frames,descriptors] = sift(I, ’Verbosity’, 1) ;
The pair option-value ’Verbosity’,1 causes the function to print a detailed progress report.
The sift function returns a 4×K matrix frames containing the SIFT frames and a 128×K matrix
descriptors containing their descriptors. Each frame is characterized by four numbers which are in
order (x
1
, x
2
) for the center of the frame, σ for its scale and θ for its orientation. The coordinates
(x
1
, x
2
) are relative to the upper-left corner of the image, which is assigned coordinates (0, 0), and may
be fractional numbers (sub-pixel precision). The scale σ is the smoothing level at which the frame has
been detected. This number can also be interpreted as size of the frame, which is usually visualized as
a disk of radius 6σ. Each descriptor is a vector describing coarsely the appearance of the image patch
corresponding to the frame (further details are discussed in Appendix A.3). Typically this vector has
dimension 128, but this number can be changed by the user as described later.
Once frames and descriptors of two images I
1
and I
2
have been computed, siftmatch can be used
to estimate the pairs of matching features. This function uses Lowe’s method to discard ambiguous
matches [1]. The result is a 2 × M matrix, each column of which is a pair (k
1
, k
2
) of indices of
corresponding SIFT frames.
Example 2 (Matching). Let us assume that the images I1 and I2 have been loaded and processed as
in the previous example. The code
matches = siftmatch(descriptors1, descriptors2) ;
stores in matches the matching pairs, one per column.
The package provides some ancillary functions; you can
• use plotsiftframe to plot SIFT frames;
• use plotsiftdescriptor to plot SIFT descriptors;
• use plotmatches to plot feature matches;
• use siftread to read files produced by Lowe’s implementation.
Example 3 (Visualization). Let I1, I2 and matches be as in the previous example. To visualize the
matches issue
plotsiftmatches(I1,I2,frames1,frames2,matches)
The sift function has many parameters. The default values have been chosen to emulate Lowe’s
original implementation. Although our code does not result in frames and descriptors that are 100%
equivalent, in general they are quite similar.
2.1 Scale space parameters
The SIFT detector and descriptor are constructed from the Gaussian scale space of the source image
I(x). The Gaussian scale space is the function
G(x; σ)
∆
= (g
σ
∗ I)(x)
where g
σ
is an isotropic Gaussian kernel of variance σ
2
I, x is the spatial coordinate and σ is the scale
coordinate. The algorithm make use of another scale space too, called difference of Gaussian (DOG),
which is, coarsely speaking, the scale derivative of the Gaussian scale space.
Since the scale space G(x; σ) represents the same information (the image I(x)) at different levels
of scale, it is sampled in a particular way to reduce redundancy. The domain of the variable σ is
2
评论2
最新资源