资源描述:
《建立资料库式.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、一、建立資料庫程式%file_namecreatingdatabaseforimagematchingclearallth=178;xframe=192;yframe=248;cxcenter=(xframe+1)/2;cycenter=(yframe+1)/2;fid3=fopen('d:dreamaaa.txt','w');fileref1{1,1}='d:dreams9';fileref1{1,2}='d:dreams2';fileref1{1,3}='d:dreams3';fileref1{1,4}='d:dreams4';filer
2、ef1{1,5}='d:dreams5';fileref1{1,6}='d:dreams6';fileref1{1,7}='d:dreams7';fileref1{1,8}='d:dreams8';fileref1{1,9}='d:dreams9';fileref1{2,1}='d:dreamw1';fileref1{2,2}='d:dreamw2';fileref1{2,3}='d:dreamw3';fileref1{2,4}='d:dreamw4';fileref1{2,5}='d:dreamw5';fileref1{
3、2,6}='d:dreamw6';fileref1{2,7}='d:dreamw7';fileref1{2,8}='d:dreamw8';fileref1{2,9}='d:dreamw9';fileref1{3,1}='d:dreamt1';fileref1{3,2}='d:dreamt2';fileref1{3,3}='d:dreamt3';fileref1{3,4}='d:dreamt4';fileref1{3,5}='d:dreamt5';fileref1{3,6}='d:dreamt6';fileref1{3,7}
4、='d:dreamt7';fileref1{3,8}='d:dreamt8';fileref1{3,9}='d:dreamt9';fileref1{4,1}='d:dreamg1';fileref1{4,2}='d:dreamg2';fileref1{4,3}='d:dreamg3';fileref1{4,4}='d:dreamg4';fileref1{4,5}='d:dreamg5';fileref1{4,6}='d:dreamg6';fileref1{4,7}='d:dreamg7';fileref1{4,8}='d:
5、dreamg7';fileref1{4,9}='d:dreamg7';[mref,nref]=size(fileref1);fori1=1:mref;ifi1==4;nref=7;endforj1=1:nref;name1=strcat(fileref1{i1,j1},'.bmp');in_img=imread(name1,'bmp');in_img1=rgb2gray(in_img);in_img1=double(in_img1);b=size(in_img1);m=b(1,1);n=b(1,2);%-----中值濾波-----in_img2=medi
6、_op(in_img1);%----------------------%-----轉成只有邏輯的0跟1(二值化)-----fori=1:m;forj=1:n;ifin_img2(i,j)<=thin_img2(i,j)=1;elsein_img2(i,j)=0;endendend%--------------------------------------------imshow(in_img2);forr4=1:2:4;ifr4>1in_img2=rot90(in_img2,r4-1);end%-----找出起始值和結束值,x方向有值得長度-----k12=
7、sum(in_img2,1);[xstart,xend]=startend(k12);xleng=xend-xstart+1;%--------------------------------------------------------------%-----同理(y方向)-----k12=sum(in_img2',1);[ystart,yend]=startend(k12);yleng=yend-ystart+1;%--------------------------WHratio=xleng/yleng;%-----找出x,y的中心,點數-----[xc
8、enter,ycente