Why am I getting these incorrect values for the dct2 function?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Oleg Komarov
el 21 de Ag. de 2011
Please format the code: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
Respuesta aceptada
Oleg Komarov
el 21 de Ag. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!