4

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 and hence I am using this implementation. https://stackoverflow.com/a/26227854/6677891

Community
  • 1
  • 1
gaya
  • 463
  • 2
  • 6
  • 22
  • you can run RANSAC on the matches you get from the BF-Match, test the validity of the homography matrix from [here](http://stackoverflow.com/questions/14954220/how-to-check-if-obtained-homography-matrix-is-good) or [here](http://stackoverflow.com/questions/42505299/finding-if-two-images-are-similar/42515173#42515173) and transform. Ofcourse Euclidean should work too. I kind of don't get why you are stuck – Rick M. Mar 31 '17 at 13:00
  • @RickM. Yes I could solve it. Thank you. – gaya Apr 04 '17 at 13:25
  • Was my solution helpful? – Rick M. Apr 04 '17 at 13:43
  • Yes it was :) @RickM. – gaya Apr 04 '17 at 14:31
  • I will post it as an answer, accept it for people needing help in the future :) Glad it helped! – Rick M. Apr 04 '17 at 14:32

3 Answers3

1

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

Community
  • 1
  • 1
Rick M.
  • 3,045
  • 1
  • 21
  • 39
0

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

Aymen Alsaadi
  • 1,329
  • 1
  • 11
  • 12
0

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.

Amar Khan
  • 11
  • 1