Why am I getting these incorrect values for the dct2 function?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Oleg Komarov
2011년 8월 21일
Please format the code: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
채택된 답변
Oleg Komarov
2011년 8월 21일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!