gaya
gaya

Reputation: 465

Finding the image with best matches from multiple images for SIFT BF-Match

I have read many questions about matching one image with a number of images using SIFT and Brute-Force matching like this and this. Is it possible to do many-with-one kind of matching? What I would like to do is the following.

  1. loop through query images in a directory
  2. for every image extract SIFT key-points and descriptors
  3. do a matching with every train/template image (again with SIFT)
  4. get the template image which has the best match (wrt minimum Euclidean distance for example?)
  5. use this best template image and compute the affine transformation between this template image and current query image.

Till now I am successful till step 3 and stuck at that point.

I am using Opencv 2.7.12 and python 2.7. Since there is no drawMatchesin this version, I am using this implementation.

Upvotes: 4

Views: 4757

Answers (3)

Amar Khan
Amar Khan

Reputation: 11

The easy way is to make a for loop over each image pair and using it to find the average error of the n best matches. Then select the matches or image pair with the lowest error.

Upvotes: 0

Aymen Alsaadi
Aymen Alsaadi

Reputation: 1517

I would suggest the following :

Create a workflow for your image matching procedure to get the best matches :

For every pair of images in your database do:

  1. Stage 1: Perform any image contrast enhancement before you apply SIFT (Image preprocessing) check this here.
  2. Stage 2: Run SIFT and extract the set of matches from every pair of images as a CSV file.
  3. Stage 3: Run RANSAC on every generated CSV file to eliminate any outliers.

Also, it would be great if you can run every workflow concurrently that would give you a short execution time.

check this workflow to give you a better idea : enter image description here

Upvotes: 0

Rick M.
Rick M.

Reputation: 3115

Step 1: Run RANSAC on the matches you get from the BF-Match.

Step 2: test the validity/goodness of the homography matrix like here

Step 3: If the homography matrix is good, transform.

Ofcourse Euclidean should work too

Upvotes: 1

Related Questions