1

My test feature vector is 'testpg' and trained feature vector is 'trainpg' and both are of dimension 2000*1 .I am aiming to find the distance between the two histogram feature vectors and hence i do

distance =  norm(trainpg-testpg)

Next I compare it to a scalar threshold value to check whether it satisfies my condition , The above code works well as i get a scalar value of this distance ie : for eg distance = 5.4 which is a scalar

But when I change code to use any other histogram based distance metric it doesn't work

i used the pdist2 function from http://www.mathworks.com/matlabcentral/fileexchange/29004-feature-points-in-image--keypoint-extraction/content/FPS_in_image/FPS%20in%20image/Help%20Functions/SearchingMatches/pdist2.m

The new code I used is

distance = pdist2(trainpg,testpg, 'chisq') d = size(distance)

Here I am getting subscripted assignment dimension mismatch error as the dimensions of my distance are now 2000*2000 instead of 1*1

How could I get scalar value for the distances?

shr m
  • 27
  • 1

1 Answers1

0

If the dimensions are 2000 x 1 for both of your feature vectors, then you should do:

distance = pdist2(trainpg.',testpg.', 'chisq');

pdist2 considers each row as a different sample. Thus you need to take the transpose, telling MATLAB that its a 2000-D feature of a single example rather than 1-D feature for 2000 examples. As a side note, you may want to check Histogram intersection distance, if your feature is a histogram. Look here for the code.

Autonomous
  • 8,935
  • 1
  • 38
  • 77