Why am I getting these incorrect values for the dct2 function?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
Basically, I'm taking the dct2 function of certain fingerprint images and then comparing them. Naturally, the image of the same person's fingers should have the lowest difference. THis is my code:
For inputting my main comparison image:
A=imread('r1.jpg');
A=imresize(A,[128,128]);
A=dct2(A);
For the image of another to be compared::
B=zeros(128,128,5);
C=imread('m1.jpg');
C=imresize(C,[128,128]);
C=dct2(C);
B(:,:,1)=C;
There are five such images. My comparison loop is:
val=999;
for i=1:5
mean2((A)-(B(:,:,i))).^2
if mean2((A)-(B(:,:,i))).^2<val
val=(mean2((A)-(B(:,:,i))).^2)
m=i
end
end
disp(m)
Now, all five pictures are from different people other than A except the fifth one.
1: 0.0186 2: 0.0037 3. 9.3263e-004 4. 0.0103 5. 0.0017
Now, the answer should be the fifth one. But due to the 3rd erratic value, it comes as 3. Why do I get such a value? What is the remedy for it? Is it the image...or the code? However, I get values such as this after comparing:
1 Kommentar
Oleg Komarov
am 21 Aug. 2011
Please format the code: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
Akzeptierte Antwort
Oleg Komarov
am 21 Aug. 2011
You have to you have to square the differences not the mean:
mean2((A - B(:,:,i)).^2)
or the means of symmetric distributions (of differences) with same first central moment will be equal.
EDIT
vals = zeros(5,1);
for ii = 1:5
vals(ii) = mean2((A - B(:,:,ii)).^2);
end
[m,idx] = min(vals);
Calculate the differences for all images and just pinpoint the minimum.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!