Sift is a very classical algorithm for image matching, but very complicated, want to own C or C + + implementation is very troublesome, if just use, there are some foreign high maintenance of SIFT library, the early stage as long as they can call, the key is to be familiar with the general flow, the SIFT library has an understanding, The exact work is done by simply calling the function. Match effect:
Sift is a very classical algorithm for image matching, but very complicated, want to own C or C + + implementation is very troublesome, if just use, there are some foreign high maintenance of SIFT library, the early stage as long as they can call, the key is to be familiar with the general flow, the SIFT library has an understanding, The exact work is done by simply calling the function.
Introduction of SIFT
1, SIFT algorithm application typical occasions:
Object recognition
Robot positioning and navigation
Image stitching
Three dimensional modeling
Gesture recognition
Video tracking
Note identification
Fingerprint and human face recognition
Feature extraction of crime scene
2, SIFT algorithm to solve the problem
Rotation, scaling, translation (RST) of the target
Image affine/projective transformation (viewpoint viewpoint)
Illumination effects (illumination)
Target occlusion (occlusion)
Clutter Scene (clutter)
Noise
Ii. Basic concepts of SIFT
1, the definition of SIFT matching
Sift matching (scale-invariant feature transform, scale invariant feature conversion) is a computer vision algorithm used to detect and describe the local feature in the image, it looks for the extremum point in the spatial scale, and extracts its position, scale, rotation invariants, this algorithm by David Lowe, published in 1999, summed up the completion of 2004. Its application range includes object identification, robot map perception and navigation, image stitching, 3D model building, gesture recognition, image tracking and motion alignment.
The description and detection of local image features can help identify objects, and SIFT characteristics are based on the points of interest of some local appearances on an object and are independent of the size and rotation of the image. Tolerance for light, noise, and slight changes in angle is also quite high. Based on these features, they are highly significant and relatively easy to retrieve, and are easily recognizable and rarely misunderstood in a database of large numbers of female characters. Using the SIFT feature to describe the detection rate of some object masking is also very high, even need more than 3 sift object characteristics is enough to calculate the position and azimuth. Under the current computer hardware speed and small feature database, the identification speed can be approximated to the real-time operation. The information of SIFT features is large and suitable for fast and accurate matching in mass database.
2, the main characteristics of SIFT characteristics
Theoretically, sift is a kind of similar invariant, that is, the image scale change and rotation is invariant. However, due to the construction of SIFT features, special treatment is made on many details, which makes the sift have a strong adaptability to the complex deformation and illumination of the image, and the operation speed is faster and the positioning accuracy is higher. Such as:
The dog operator is used to detect the key points in multi-scale space, and the computation speed is much faster than the traditional detection method based on log operator.
The precise positioning of the key points not only improves the precision, but also greatly improves the stability of the key points;
The adaptive ability of the local deformation of the image is improved by the statistical characteristics of the sub region, rather than the single pixel as the object of the construction description.
For the 16*16 Key Point neighborhood and 4*4 region, the weighted processing of Gaussian function is carried out in the process of gradient amplitude, which strengthens the central region and weakens the influence of the edge region, thus improving the adaptability of the algorithm to geometric deformation.
This method not only has invariance to the general linear illumination model, but also has certain adaptability to the complex illumination change. For details on this part, refer to the literature "distinctive Image Features from Scale-invariant keypoints"
Features of SIFT algorithm:
A.sift feature is the local feature of the image, which is invariant to rotation, scaling and brightness, and maintains a certain degree of stability to the change of angle of view, affine transformation and noise.
B. Unique (distinctiveness) good, informative, suitable for fast and accurate matching in massive feature database;
C. Multi-scale, even a few objects can produce a large number of sift eigenvector;
D. High-speed, optimized sift matching algorithm can even achieve real-time requirements;
E. Scalability, which can be easily combined with other forms of eigenvector.
Application of SIFT algorithm
1, the main function of SIFT[CPP] View plain copy #include "sift.h" #include "imgfeatures.h" #include Kdtree.h " #include " utils.h " #include " xform.h " # include <cv.h> #include <cxcore.h> #include
Sift (Scale invariantfeature Transform) is a good image matching algorithm, simultaneously can handle the brightness, translation, rotation, scale changes, using feature points to extract feature descriptors, and finally find a matching feature descriptor.
Sift Library Analysis:
A total of 6 files plus a main.c file are included.
Untils.c
Minpq.c
Imgfeature.c
Sift.c
Xform.c
Kdtree.c
With its corresponding. h file
The core documents are sift.c and kdtree.c.
1 sift.c looking for feature points in a picture
Main steps:
A, the construction scale space, detects the extreme point, obtains the scale invariance;
b, feature point filtering and accurate positioning, remove the unstable feature points;
C, extracting feature descriptors at feature points, assigning directional values for feature points;
D, the feature descriptor is generated and the feature descriptor is used to find the matching point.
The neighborhood of 16*16 is taken as the sampling window with the feature point as the center,
The relative direction of the sampling point and the feature point is classified into a directional histogram containing 8 bin by Gaussian weighting.
Finally, the 128-D feature descriptor of 4*4*8 is obtained.
2 kdtree.c to match two images
Main steps:
When the SIFT feature vectors of two images are generated, the next step is to use the Euclidean distance of the feature vectors of the key points as the similarity judgment measure of the key points in the two images.
Take a key point in Figure 1 and traverse to find the two key points in image 2 that are closest to the distance. In these two key points, a pair of matching points is determined if the secondary close is divided by the nearest distance and less than a threshold.
3 imgfeature.c is marked in the above picture. The point at which the connection corresponds.
Iv. Analysis of specific documents
1, Utils.h
Utils is a SIFT algorithm based on a comparison of header files, mainly on the image of the basic manipulation:
Gets the pixel point of a location
Set the pixel point of a location (8-bit, 32-bit, and 64-bit),
Calculates the square of the distance between two points
Draw an "X" at some point in the picture
Combine two pictures into one, high is the sum of the two, width is the larger of both. IMG1 in the upper left corner, Img2 in the lower right corner.
The function is interpreted as follows:
static int Pixval8 (iplimage *img, int r,int c)
Get some pixel from a grayscale image
static void setpix8 (Iplimage *img, int r,int c, Uchar val)
Set pixels for a point in a grayscale image
static float pixval32f (Iplimage *img, intr, int c)
static void setpix32f (Iplimage *img, intr, int c, float val)
Static double pixval64f (Iplimage *img, intr, int c)
static void setpix64f (Iplimage *img, intr, int C, double val)
Get and set pixel values for a point in 32-bit and 64-bit images
void Fatal_error (char *format,...)
Error handling, with vs2010+opencv2.3 errors, directly to the internal implementation of the annotation can be, no impact.
char * replace_extension (const char *file,const char *extn)
Gets the full name of a file, connecting the file name and extension together like traffic + JPG => traffic.jpg
char * prepend_path (const char *path,const char *file)
Gets the full path of a file, adding the pathname to the filename before c:\\ + traffic.jpg => c:\\traffic.jpg
char * basename (const char *pathname)
Remove the path from the filename c:\\traffic.jpg => traffic.jpg
void progress (int done)
Show the progress of the program, expressed in |/-\
int array_double (void **array, int n, int size)
Double array length
Double dist_sq_2d (cvpoint2d64f p1, cvpoint2d64f p2)
Calculate the diagonal distance of two points
void draw_x (Iplimage *img, Cvpoint pt, int r, int w, cvscalar color)
At Point pt draw a fork, the essence is to draw four lines at that point
Iplimage * STACK_IMGS (iplimage *img1,iplimage *img2)
Two pictures generate a picture, high is the sum of both, width is the larger of both
int win_closed (char *name)
To see if a window has been closed
Utils.h[CPP] View Plain copy/** @file miscellaneous utility functions. copyright (C) 2006-2010 rob hess