How to find Euclidean distance for SIFT Features?

2 views (last 30 days)
Malini
Malini on 19 Dec 2013
Edited: Malini on 20 Dec 2013
Dear Team,
I'm doing research in image retrieval using SIFT features. I've to compute SIFT features for 100 images and compare with the SIFT feature of query image using euclidean distance.And retrieve the top 10 best match images alone.
I've computed the SIFT features for 100 images and stored them in a cell array. I've also computed the SIFT features of query image. When i tried using euclidean distance i'm facing problem here.
Here is the code for my distance comparison
for j = 1:100 % database size is 100
[row cols] = size(dbfeatures{j}.Features); % no.of features selected is different for each image in database
for p = 1:row
for q = 1:cols
dd1(j) = Euclidean_Distance(queryfeatures.Features,dbfeatures{j}.Features(p,q));
end
end
end
Code is executing fine without error but not as expected. I'm facing problem with Euclidean_Distance This is the code i've used for euclidean distance
function fdist = Euclidean_Distance(p, q)
bins = size(p,32);
bcoeff = 0;
for i = 1:bins
bcoeff = bcoeff + (p(i) - q(i)).^2;
end
fdist = sqrt(double(bcoeff));
When i tried testing Euclidean_distance input step by step in command window as
queryfeatures.Features(1,1) - ans is 60
dbfeatures{1}.Features(1,1) - ans is 63
Euclidean_Distance(60,63) - ans is 3
Problem is here in below code
Euclidean_Distance(queryfeatures.Features(1,1),dbfeatures{1}.Features(1,1))
ans is 0
Could you please let me know why i'm getting 0 instead of 3. Tried thinking what is going wrong in the above step but couldn't catch :(. please help
Malini

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!