1

The objective is to see if two images, which have one object captured in each image, matches.

The object or image I have stored. This will be used as a baseline:

  • item1 (This is being matched in the code)

The object/image that needs to matched with-this is stored:

  • input (Need to see if this matches with what is stored

My method:

  1. Covert images to gray-scale.
  2. Extract SURF interest points.
  3. Obtain features.
  4. Match features.
  5. Get 50 strongest features.
  6. Match the number of strongest features with each image.
  7. Take the ratio of- number of features matched/ number of strongest features (which is 50).

If I have two images of the same object (two images taken separately on a camera), ideally the ratio should be near 1 or near 100%. However this is not the case, the best ratio I am getting is near 0.5 or even worse, 0.3.

I am aware the SURF detectors and features can be used in neural networks, or using a statistics based approach. I believe I have approached the statistics based approach to some extent by using 50 of the strongest features.

Is there something I am missing? What do I add onto this or how do I improve it? Please provide me a point to start from.

%Clearing the workspace and all variables
clc;
clear;

%ITEM 1
item1 = imread('Loreal.jpg');%Retrieve order 1 and digitize it.
item1Grey  = rgb2gray(item1);%convert to grayscale, 2 dimensional matrix
item1KP = detectSURFFeatures(item1Grey,'MetricThreshold',600);%get SURF dectectors or interest points
strong1 = item1KP.selectStrongest(50);
[item1Features, item1Points] = extractFeatures(item1Grey, strong1,'SURFSize',128); % using SURFSize of 128

%INPUT : Aquire Image
input= imread('MakeUp1.jpg');%Retrieve input and digitize it.
inputGrey  = rgb2gray(input);%convert to grayscale, 2 dimensional matrix
inputKP = detectSURFFeatures(inputGrey,'MetricThreshold',600);%get SURF dectectors or interest
strongInput = inputKP.selectStrongest(50);
[inputFeatures, inputPoints] = extractFeatures(inputGrey, strongInput,'SURFSize',128); % using SURFSize of 128

pairs = matchFeatures(item1Features, inputFeatures, 'MaxRatio',1); %matching SURF Features
totalFeatures = length(item1Features); %baseline number of features
numPairs = length(pairs); %the number of pairs
percentage  = numPairs/50;

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

The baseline image

The input image

Community
  • 1
  • 1
Kal
  • 73
  • 1
  • 8
  • Could you post some sample images, please. – kkuilla Oct 07 '14 at 08:22
  • I uploaded the images using tinypic. There taken with the same camera-took the picture twice. They should return at least 90% using the ratio setup I have. – Kal Oct 07 '14 at 19:09
  • Thank you rayryeng for that picture edit. Much cleaner. – Kal Oct 07 '14 at 19:15
  • I believe the issue to the best of my understanding is whether using `matchFeatures` is the best effort or should a different algorithm be used. I was thinking about using BRISK, but `detectBRISKFeatures` is not recognized as a function in my 2013a version of MATLAB. Maybe using a other feature like FAST should be used with SURF points? – Kal Oct 07 '14 at 19:35
  • [Algorithm improvement for Coca-Cola can shape recognition](http://stackoverflow.com/q/10168686/2545927) might be useful. There are answers that talk about SURF. – kkuilla Oct 08 '14 at 08:03

1 Answers1

1

I would try not doing selectStrongest and not setting MaxRatio. Just call matchFeatures with the default options and compare the number of resulting matches.

The default behavior of matchFeatures is to use the ratio test to exclude ambiguous matches. So the number of matches it returns may be a good indicator of the presence or absence of the object in the scene.

If you want to try something more sophisticated, take a look at this example.

Dima
  • 38,860
  • 14
  • 75
  • 115
  • 'matchFeatures' would return a good number of pairs that correspond between two sets of features. In order to see if the number of matched pairs is a good enough number of pairs, I compare to the number of pairs that the baseline image has. I take the ratio of that and the ratio I am getting is around 0.4 and 0.5. Is that good enough in terms of object matching by using features? – Kal Oct 07 '14 at 19:00
  • I don't know. You are going to have to test the overall system, and tune the thresholds. – Dima Oct 07 '14 at 19:02
  • Tune the thresholds for the gray scale images or the thresholds for the point and feature functions? I tried only matching the strongest features (even tried 15), but the best ratio I could obtain was 0.5. – Kal Oct 07 '14 at 19:12
  • What I mean is that you need to check if the ratio greater than 0.4, for example, is sufficient to decide whether two images match or not. – Dima Oct 07 '14 at 20:32
  • It seems that the SURF algorithm implies that only one baseline image is needed to recognize an object. Is that really the case, because just one image of a object.. sounds not enough? – Kal Oct 13 '14 at 20:14