Ask Your Question

# KeyPoints&DMatch - What does distance stands for?

Hey Community,

I don´t understand the parameter distance in the struct DMatch.

There is often the code for get only the "good matches":

double max_dist = 0;
double min_dist = 100;
for( int i = 0; i < descriptors.rows; i++ ){
double dist = matches[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
std::vector< DMatch > good_matches;
for( int i = 0; i < descriptors.rows; i++ ){
if( matches[i].distance <= 2*min_dist ) {
good_matches.push_back( matches[i]);
}
}


But distance? What is this? It is a float, less than 1. But I can´t get a context between the distance and the pixel to pixel distance.

Say, a DMatch has his query by pixel (25, 50) [first image] and his train by (35, 50) [second image]. For me, the distance would be 10... DMatch.distance is something alá 0.065. And another distance comparison would be pixel (30, 65) and (40, 65). Again 10 pixel but DMatch.distance would be 0.062?!?

Anyone can help me, please?

edit retag close merge delete

## 1 answer

Sort by » oldest newest most voted

This highly depends on what kind of matcher you use. For example bruteforce matching returns the hamming distance of those matched keypoints which equals integer numbers from 0 to infinity (actually limited by the length/bits of/in the descriptor). So there is no direct answer to your question if you dont tell us what kind of matcher (and descriptor) you used.

more

## Comments

Ah....am I correct, that the distance doesn´t say me the pixel position (row, column) offset. It say me the pixel to pixel difference. So if query is COLOR(255,0,0) and the train would be (254,0,0) the hamming distance would be 1.... for me distance was a measure of length.

1

Sorry for the late answer. The example with the color is kind of bad. A descriptor is usually not a color/intensitiy. This would be too sensitive towards any kind of noise, etc. You really need to look at what the descriptors actually do. For example, SIFT calculates the histogram of gradients of a certain patch(es) around the keypoint. To compare 2 SIFT desriptors, you actually use the euclidean distance, but on the descriptor and not the keypoint location. So this distance is not a geometric distance. In the end, the distance really depends on what kind of descriptor you use (and of course of the matcher which you apply according to the type of descriptor).

Check out this answer from stackoverflow which explains distance in DMatch elegantly. https://stackoverflow.com/questions/1...

Official site

GitHub

Wiki

Documentation

## Stats

Asked: 2013-12-17 06:34:48 -0500

Seen: 1,138 times

Last updated: Dec 17 '13