Problem description -
->say we already have some no of template(base) images in one folder
- Image to find its perfect matching image
-Matched Image (if found)
-Otherwise Message - no matching found
I need robust solution to this ..
I have tried using SURF Features but its not giving me robust output meaning it sometimes gives wrong match - though it its giving quite good result but not 100 %
Here is the rough logic of my current algorithm :
Input_Image_gray = rgb2gray(Input_Image);
Input_keys = detectSURFFeatures(Input_Image_gray);
[Input_features Input_validPts] = extractFeatures(Input_Image_gray, Input_keys);
----iterate for loop for the Template images we have in a Folder
ref_img_gray = rgb2gray(templateImage);
[~, MATCH_METRIC] = matchFeatures(ref_features,Input_features ,'MatchThreshold',3);
-- Calculate percentage for each image on the base of MATCH_MATRIC
if percentage > 50
display the matched Image
otherwise display message - no matching image fond
please share if any body has any idea regarding how to achieve this
Thanks in advance..
When solving registration problems, there is typically not any one algorithm that will be robust 100% of the time. That said, you may find that you can achieve very good results with a particular dataset if you choose your algorithm appropriately.
As far as which algorithm to use, you should consider the following questions:
1) What types of geometric deformations do you expect are present in your data? 2) Do the images in your dataset have strong features in terms of Corners, SURF features, etc. 3) Are all the images in your dataset collected with a similar sensor? 4) Are all of the images in your dataset illuminated the same?
You have mentioned already that there is skew present in your images. The presence of shear means that you require an affine model to solve the registration.
You will not be able to use normxcorr2, because there is no known correlation based approach for resolving shear.
If you are getting good results with feature based approach using SURF and estimateGeometricTransform in CVST, I would see if you can tune the feature matching and RANSAC steps to get the kind of robustness you are looking for. SURF is an appropriate algorithm for solving affine registration problems.
If you're searching for a "perfect matching image" simply subtract the two images:
diffImage = double(image1) - double(image2); perfectMatch = (sum(diffImage(:)) == 0);
You can use nnz if you want to find the percentage that aren't the very same pixel value. Only use SURF if you want to compare approximate matches, not exact matches.