conversion of floating point to integer
6 ビュー (過去 30 日間)
古いコメントを表示
My code to match a image with the images in database is :
img=handles.y;
mat=sum(img,1);
mat=mat(:);
k=zeros(30,1);
for i=1:30
str=strcat(int2str(i),'.pgm');
%concatenates two strings that form the name of the image
eval('img1=imread(str);');
mat1=sum(img1,1);
mat1=mat1(:);
k(i)=max(abs(normxcorr2(mat1,mat)));
end
%take maximum from matrix & store its value & position
vmax=max(k)
uval=int8(fix(vmax))
if uval>=1
figure(11);
op=imread('match.jpg');
imshow(op);
else
figure(12);
dp=imread('mismatch.jpg');
imshow(dp);
why int8(fix(x)) or int16(fix(x)) or int32(fix(x)) or int64(fix(x)) gives value 1 for vmax=1.0000 for few input images and gives value 0 for vmax=1.0000 for few other input images??
0 件のコメント
回答 (1 件)
Walter Roberson
2012 年 4 月 10 日
Because vmax is not exactly 1 in those other images.
3 件のコメント
Walter Roberson
2012 年 4 月 10 日
1.0000 is not necessarily slightly greater than 1. When you use "format short" then MATLAB displays all numbers within 5/10000 of 1 as 1.0000 including exactly 1 itself.
Display
vmax - 1
to see the difference between vmax and 1 .
参考
カテゴリ
Help Center および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!