1

I'm working on Content based image retrieval project using matlab when I apply the function point=detectSURFFeatures(image) I get 83*1 surf point that has the following information:

         `Scale: [83x1 single]
          SignOfLaplacian: [83x1 int8]
          Orientation: [83x1 single]
          Location: [83x2 single]
          Metric: [83x1 single]
          Count: 83`

I need to know how I can extract a (distinctive and Fixed) feature vector that represents each image in a database that contains thousands of images,any help please ?
Here is the samples of the database. (Wang database)

Dima
  • 38,860
  • 14
  • 75
  • 115
  • What's wrong with the 83 SURF points? What's wrong with applying SURF to the 1000 images and getting distinct points? – krisdestruction Apr 21 '15 at 22:05
  • but how i can to compare the query image with other features from other images ,, i want to use distance like Euclidean distance or DTW to measure distance between query image and another images – Ahmed Tarawneh Apr 21 '15 at 22:13
  • How i can use 83 SURF points to compare the images ? there is many vectors Scale , Orientation , location ... etc and its give different number of feature(value) for each image – Ahmed Tarawneh Apr 21 '15 at 22:17
  • Are there duplicate images in the database? What kind of images are you trying to match from the database? Can you post some samples in the question? – krisdestruction Apr 21 '15 at 22:34

2 Answers2

1

Currently, I am using imread to read the image as follows. Matlab's detectSURFFeatures function only works on greyscale images.

I = rgb2gray( imread( '434.jpg' ) );

You can run this line to get the SURF features.

points = detectSURFFeatures( I );

You can plot the surf features using the following.

imshow( I );
hold on;
plot( point.selectStrongest(10) );
hold off;

Here is the visualization of the image I worked with.

enter image description here

This printing the points object, you can get the following properties showing 41 features.

          Scale: [41x1 single]
SignOfLaplacian: [41x1 int8]
    Orientation: [41x1 single]
       Location: [41x2 single]
         Metric: [41x1 single]
          Count: 41

If you have all the grayscale images stored in a cell object called cellimg (one cell element for each image), you can run detectSURFFeatures on each one as follows.

cellsurf = cellfun( @(I) detectSURFFeatures( I ), cellimg, 'UniformOutput', false );

Each element of cellsurf will contain SURF points. Since you want a set of distinctive and fixed features that will identify each image, you can select the strongest points on each image in cellsurf. You can either use the top n number of features or set n = min( points ). Calculate the min number of features using the following code.

n = min( cellfun( @(S) S.Count, cellsurf ) );

Then you can select the strongest points by running selectStrongest on each cell in cellsurf.

F = cellfun( @(S) S.selectStrongest( n ), cellsurf, 'UniformOutput', false);

The variable F will contain a constant set of features. You can change n accordingly to change the number of strongest features you want. To match two sets of features, you can use the builtin matchFeatures function.

Notes

  • If you need more features, you can specify a different 'MetricThreshold' parameter when calling the detectSURFFeatures function.
  • You can use other feature algorithms instead of SURF by using the functions: detectBRISKFeatures, detectFASTFeatures, detectHarrisFeatures, detectMinEigenFeatures, detectMSERFeatures
krisdestruction
  • 1,950
  • 1
  • 10
  • 20
  • Now i have cellimg of 1*2 cell each cell contain grayscale image from the database ,,, when i apply : `cellsurf = cellfun( @(I) detectSURFFeatures( I ), cellimg );` where I is a matrix of grayscale image I get `Error using cellfun SURFPoints output type is not currently implemented.` – Ahmed Tarawneh Apr 21 '15 at 23:40
  • @AhmedTarawneh What version of Matlab are you using? Are you able to update to the latest version? – krisdestruction Apr 21 '15 at 23:53
  • yes i get surf point now as `Scale: [10x1 single] SignOfLaplacian: [10x1 int8] Orientation: [10x1 single] Location: [10x2 single] Metric: [10x1 single] Count: 10` now how i can use these point to compute distance e.g Euclidean distance .. etc in other word ** how i can retrieve similar image** **i'm using matlab 2014** – Ahmed Tarawneh Apr 22 '15 at 00:02
  • @AhmedTarawneh `SURFPoints output type is not supported. Set 'UniformOutput' to false. ` I'm assuming you got this error message. While I apologize for giving you code that didn't work, the issue was pretty clear. Anyways I updated the code to include 'UniformOutput' to false. – krisdestruction Apr 22 '15 at 00:16
  • I mean this surf point object contain more than one vector , scale vector , Orientation vector .. which of these vector i can use to represent the image ( to make a comparison ) ? – Ahmed Tarawneh Apr 22 '15 at 00:17
  • @AhmedTarawneh You can use the [matchFeatures function](http://www.mathworks.com/help/vision/ref/matchfeatures.html) to match your features. Do you need an explanation of how to use it? – krisdestruction Apr 22 '15 at 00:20
  • @AhmedTarawneh Anytime :) – krisdestruction Apr 22 '15 at 00:31
1

First of all, detectSURFFeatures only gives you the interest point locations, scales, and orientations. You also have to call extractFeatures, which will give you the SURF descriptors, that are vectors describing the image patch around each interest point.

Now, you are trying to convert a set of patch descriptors representing an image into a single vector, and there are multiple ways to do that. A popular approach is called bag of features, aka bag of visual words.

Dima
  • 38,860
  • 14
  • 75
  • 115