1
$\begingroup$

I am trying to find the difference between two images, using Matlab. The classic built in function that Matlab provides for this is because the two images don't have the same dimensions (The objects in the images are the same, but in the second image other objects are introduced). i need to use a metric or function can calculate the number of matching feature between two images and give me a value to decide according to threshold ..

source = imread('source.png');
target = imread('target.png');
source = rgb2gray(source);
target = rgb2gray(target);
  sourcePoints=detectSURFFeatures(source,'MetricThreshold',100.0,'NumOctaves',1,'N   umScaleLevels',6);
 targetPoints=detectSURFFeatures(target,'MetricThreshold',100.0,'NumOctaves',1,'NumScaleLevels',6);
     [sourceFeatures,sourcePoints]=extractFeatures(source,sourcePoints,'SURFSize',64);
     [targetFeatures,targetPoints]=extractFeatures(target,targetPoints,'SURFSize',64);

  boxPairs = matchFeatures(sourceFeatures, targetFeatures);

  matchedSourcePoints = sourcePoints(boxPairs(:, 1), :);
  matchedTargetPoints = targetPoints(boxPairs(:, 2), :);

  % IS there any metric can used to make accurate decision if there is a match or not instead of percentage because its not accurate as required 
  numPairs = length(boxpairs); %the number of pairs
  percentage  = numPairs/100;

     if percentage >= 0.40
     disp('We have this');
       else
     disp('We do not have this');
     disp(percentage);
    end

IS there any metric can used to make accurate decision if there is a match or not instead of percentage because its not accurate as required

$\endgroup$
1
  • $\begingroup$ Use feature detection and extraction from your reference frame to create kernels for 2D cross correlation on the remaining frame. Then decide on threshold, scoring logic to define a match. Start with a noise free, simple object frames to set thresholds, scoring numbers. $\endgroup$
    – docscience
    Commented Jul 7, 2015 at 19:10

2 Answers 2

0
$\begingroup$

People generally use Euclidean distances, just like you do and it works as it is, pretty well. However, if you require further robustness, I propose the following:

  1. Compute the matching both ways: image1->image2 and image2->image and then retrieve only the agreeing matches. This introduces some consensus.
  2. Assuming you have planar patches, you run a homography using RANSAC. The good thing here is that RANSAC is robust to outliers, given a predifined tolerance. This way prune away a lot of matches, and you will be left with a meaningful set of inliers.

Using these two together should really give you robust and repeatable matches.

$\endgroup$
1
  • $\begingroup$ thank you for your replay , if possible you can suggest me code to apply these things as you mention , i need your help in this manner how i can apply these things in my code and make decision according to 1st and 2nd points ,,, thanks sir $\endgroup$
    – azifallail
    Commented Jul 7, 2015 at 9:58
0
$\begingroup$

You can try estimating a geometric transformation between the matched sets of features using estimateGeometricTransform. The number of inliers returned by the function could be used to decide whether an object is present. See this example.

$\endgroup$
1
  • $\begingroup$ thank you for your replay ,,, after i applied this function and eliminate outliers i need to calculate the inlier Points for my source and target .. is there any function can calculate these points ,, and i can put a metric for example if these inliers >= number based on how many strongest point i put ,, i need to decide rather than plot square around object , thanks again $\endgroup$
    – azifallail
    Commented Jul 8, 2015 at 14:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.