Why am I getting same Euclidean Distance for different images ?

3 Ansichten (letzte 30 Tage)
I am trying to write a code that will indicate which two images are similar out of three.
% OBJECT: Comparing sift features by euclidean distance
%%Reading Images
img1=imread('106aa.jpg');
img2=imread('107aa.jpg');
img3=imread('107bb.jpg');
%%Resizing Images
resize1=imresize(img1, 0.25) ;
resize2=imresize(img2, 0.25) ;
resize3=imresize(img3, 0.25);
%%Converting rgb images to gray scale images
gray1=rgb2gray(resize1);
gray2=rgb2gray(resize2);
gray3=rgb2gray(resize3);
%%Converting to single precision
% because sift only work on single precision
Ia=single(gray1);
Ib=single(gray2);
Ic=single(gray3);
%%Extracting sift features
[fa, da] = vl_sift(Ia) ;
[fb, db] = vl_sift(Ib) ;
[fc, dc] = vl_sift(Ic) ;
[matches1, scores1] = vl_ubcmatch(da, db) ;
[matches2, scores2] = vl_ubcmatch(db, dc) ;
%%Comparing features vectors by Euclidean distance
fv1= [ 'fa' 'da' ] ;
fv2= [ 'fb' 'db' ] ;
fv3= [ 'fc' 'dc' ] ;
diff1 = fv1 - fv2;
distance1 = sqrt(diff1 * diff1')
diff2= fv2 - fv3 ;
distance2 = sqrt(diff2 * diff2')

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Jan. 2014
You can not reference variables by strings like that. If that is what you are trying to do. Perhaps you want [fa da]
  10 Kommentare
Walter Roberson
Walter Roberson am 9 Jan. 2014
No it is not possible to subtract vectors of different size. You should be designing your feature vectors so that they are all the same length, and within the feature vectors each sub-group of values should have the same relative offset. You can pad subgroups within feature vectors.
For example, if DCT coefficients start at index 3143 in the first feature vector and extend for 128 values, then the second feature vector should store its DCT coefficients at index 3143 for length 128 as well.
Explorer
Explorer am 10 Jan. 2014
Okay thanks a lot for guiding.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 6 Jan. 2014
21.4.2.7 American Sign Language, ASL Recognition
21.4.2.7.1 Sign Language, Other Languages, Chinese, Arabic
21.4.2.7.2 Sign Language, Fingerspelling

Community Treasure Hunt

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

Start Hunting!

Translated by