13年数模B题代码_第1页
13年数模B题代码_第2页
13年数模B题代码_第3页
13年数模B题代码_第4页
13年数模B题代码_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

附件1代码:I1=cell(1);I2=cell(1);for i=1:10 I11,i=imread(C:UsersAdministratorDesktopall2013cumcm2013problemsB附件100,num2str(i-1),.bmp);endfor i=11:19 I11,i=imread(C:UsersAdministratorDesktopall2013cumcm2013problemsB附件10,num2str(i-1),.bmp);endfor temp=1:size(I1,2)for i=1:size(I1temp,1) for j=1:size(I1temp,2) if(I1temp(i,j)=255) I2temp(i,j)=0; else I2temp(i,j)=1; end endendendstart=0;for i=1:size(I2,2)n=0; for j=1:size(I2i,1) if(I2i(j,1)=1) n = n + 1; end end if(n=size(I2i,1) start=i; break; endendstart1=start;f=zeros(size(I2,2),1);f(start)=1;ornum=1;order(ornum)=start1;for t=1:size(I2,2)-1for i=1:size(I2,2) if(f(i)=1) temp(i)=0; for j=1:size(I2start,1) temp(i)=temp(i)+abs(I2start(j, size(I2start,2) - I2i(j,1); end else temp(i)=; endendtt order(ornum)=min(temp);f(order(ornum)=1;start=order(ornum);ornum=ornum+1;endorderI1=cell(1);for i=0:18 I11,i+1=imread(sprintf(C:Documents and SettingsAdministrator桌面all2013cumcm2013problemsB附件1%03d.bmp,i);endA=for i=1:19A=A,I1seq(i);endimshow(A)附件2:I1=cell(1);I2=cell(1);for i=1:10 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件200,num2str(i-1),.bmp);endfor i=11:19 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件20,num2str(i-1),.bmp);endfor temp=1:size(I1,2)for i=1:size(I1temp,1) for j=1:size(I1temp,2) if(I1temp(i,j)=255) I2temp(i,j)=0; else I2temp(i,j)=1; end endendendstart=0;for i=1:size(I2,2)n=0; for j=1:size(I2i,1) if(I2i(j,1)=1) n = n + 1; end end if(n=size(I2i,1) start=i; break; endendstart1=startf=zeros(size(I2,2),1);f(start)=1;ornum=1;order(ornum)=start1;for t=1:size(I2,2)-1for i=1:size(I2,2) if(f(i)=1) temp(i)=0; for j=1:size(I2start,1) temp(i)=temp(i)+abs(I2start(j, size(I2start,2) - I2i(j,1); end else temp(i)=; endendt order(ornum)=min(temp);f(order(ornum)=1;start=order(ornum);ornum=ornum+1;endorderI1=cell(1);for i=0:18 I11,i+1=imread(sprintf(C:Documents and SettingsAdministrator桌面all2013cumcm2013problemsB附件2%03d.bmp,i);endA=for i=1:19A=A,I1seq(i);endimshow(A)附件3:I1=cell(1);I2=cell(1);for i=1:10 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件300,num2str(i-1),.bmp);endfor i=11:100 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件30,num2str(i-1),.bmp);endfor i=101:209 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件3,num2str(i-1),.bmp);endfor temp=1:size(I1,2)for i=1:size(I1temp,1) for j=1:size(I1temp,2) if(I1temp(i,j)= 1) break; else wh(i)=wh(i)+1; end endendttemp=;for i=1:size(wh,2) if(wh(i)35&wh(i)50) ttemp=ttemp,i; endendttempI3=cell(1);for i=1:19 for k=1:size(I2i,1) for j=1:size(I2i,2) I3i(k,j)=I2ttemp(i)(k,j); end endendstart=0;for i=1:size(I3,2)n=0; for j=1:size(I3i,1) if(I3i(j,1)=1) n = n + 1; end end if(n=size(I3i,1) start=i; break; endendtemp=zeros(size(I3,2),1);flag=zeros(size(I3,2),1);flag(start)=1;ornum=1;order(ornum)=start;for t=1:size(I3,2)-1for i=1:size(I3,2) if(flag(i)=1) temp(i)=0; for j=1:size(I3start,1) temp(i)=temp(i)+abs(I3start(j, size(I3start,2) - I3i(j,1); end else temp(i)=; endendornum=ornum+1;tt order(ornum)=min(temp);flag(order(ornum)=1;start=order(ornum);endfor i=1:19 ab(i)=ttemp(order(i);endabI1=cell(1);I2=cell(1);for i=1:10 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件300,num2str(i-1),.bmp);endfor i=11:100 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件30,num2str(i-1),.bmp);endfor i=101:209 I11,i=imread( C:UsersAdministratorDesktopall2013cumcm2013problemsB附件3,num2str(i-1),.bmp);endfor temp=1:size(I1,2)for i=1:size(I1temp,1) for j=1:size(I1temp,2) if(I1temp(i,j)= 1) break; else wh(i)=wh(i)+1; end endendttemp=;for i=1:size(wh,2) if(wh(i)10) ttemp=ttemp,i; endendttempimgs=cell(1);imgst=cell(1);for i=1:19 imgsti=I1ab(i);endA=7 202137465364686970737980848697100117127132163164171178203;for i=1:length(A)imgsi=I1A(i);endleftimg=I162;temp=zeros(length(A),1);f=zeros(length(A),1);order=;order(1)=62; num=1;for num=1:18for i=1:length(A) if(f(i)=1) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(I1A(i)(:,1); temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendtt order(length(order)+1)=min(temp);f(order(length(order)=1;leftimg=I1A(order(length(order);endC1=I162;USE(62)=1;for i=2:19 C1=C1,I1A(order(i); A(order(i)USE(A(order(i)=1;endC=C;C1;imshow(C)imgst=cell(1);imgst1=I162;for i=2:19 imgsti=I1A(order(i);endA=213192427313240425152637477838788101108116121129143148160161170177180192196204;for i=1:length(A)imgsi=I1A(i);endleftimg=I1169;temp=zeros(length(A),1);f=zeros(length(A),1);order=;order(1)=169; num=1;for num=1:18for i=1:length(A) if(f(i)=1) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(I1A(i)(:,1); temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendtt1 j1=min(temp);%temp(j1)=99999;order(length(order)+1)=j1;f(order(length(order)=1;leftimg=I1A(order(length(order);endorderorder(19)=3;order(18)=17;C2=I1169;USE(169)=1;for i=2:19 C2=C2,I1A(order(i);A(order(i)USE(A(order(i)=1;endC=C;C2;imshow(C)leftimg=I139;A=start=39;pra=2;for i=1:209 if USE(i)=0 if (fs(i,1)=fs(start,1) & abs(fs(i,2)-fs(start,2)=pra | fs2(i,1)=fs2(start,1) & abs(fs2(i,2)-fs2(start,2)=pra) A=A i; end endendtemp=zeros(length(A),1);f=zeros(length(A),1);order=;order(1)=39; num=1;for num=1:18for i=1:length(A) if(f(i)=1) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(I1A(i)(:,1); temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendtt1 j1=min(temp);%temp(j1)=99999;order(length(order)+1)=j1;f(order(length(order)=1;leftimg=I1A(order(length(order);endorderC3=I139;USE(39)=1;for i=2:19 C3=C3,I1A(order(i);A(order(i)USE(A(order(i)=1;endC=C;C3;imshow(C)leftimg=I115;A=start=15;pra=2;for i=1:209 if USE(i)=0 if (fs(i,1)=fs(start,1) & abs(fs(i,2)-fs(start,2)=pra | fs2(i,1)=fs2(start,1) & abs(fs2(i,2)-fs2(start,2)fs(start,2)+2 temp(i)=99999; else temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(I1A(i)(:,1); temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); end else temp(i)=99999; endendtt1 j1=min(temp);%temp(j1)=99999;order(length(order)+1)=j1;start=A(j1);f(order(length(order)=1;leftimg=I1A(order(length(order);endorderC4=I115;USE(15)=1;for i=2:19 C4=C4,I1A(order(i);A(order(i)USE(A(order(i)=1;endC=C;C4;imshow(C)imgst=cell(1);%imgst1=I1169;for i=1:19 imgsti=I1order(i)+1;endleftimg=I195;A=;%USE(95)=1;start=95;pra=2;for i=1:209 if USE(i)=0 if (fs(i,1)=fs(start,1) & abs(fs(i,2)-fs(start,2)=pra | fs2(i,1)=fs2(start,1) & abs(fs2(i,2)-fs2(start,2)=pra) A=A i; end endendtemp=zeros(length(A),1);f=zeros(length(A),1);order=;order(1)=95; num=1;for num=1:18for i=1:length(A) if(f(i)=1) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(I1A(i)(:,1); temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendtt1 j1=min(temp);%temp(j1)=99999;order(length(order)+1)=j1;f(order(length(order)=1;leftimg=I1A(order(length(order);endorderC5=I195;USE(95)=1;for i=2:19 if(i=6) C5=C5,I1A(order(i); A(order(i) USE(A(order(i)=1; else C5=C5,I148; USE(48)=1; 48 endendC=C;C5;imshow(C)imgst=cell(1);imgst1=I195;for i=2:19 %order(i) %A(order(i) imgsti=I1A(order(i);endimgst6=I148;leftimg=I1126;A=;start=126;pra=2;for i=1:209 if USE(i)=0 if (fs(i,1)=fs(start,1) & abs(fs(i,2)-fs(start,2)=pra | fs2(i,1)=fs2(start,1) & abs(fs2(i,2)-fs2(start,2)=pra) A=A i; end endendtemp=zeros(length(A),1);f=zeros(length(A),1);order=;order(1)=126; num=1;for num=1:18for i=1:length(A) if(f(i)=1) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(I1A(i)(:,1); temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendtt1 j1=min(temp);%temp(j1)=99999;order(length(order)+1)=j1;start=A(j1);f(order(length(order)=1;leftimg=I1A(order(length(order);endorderC6=I1126;USE(126)=1;for i=2:19 C6=C6,I1A(order(i);A(order(i)USE(A(order(i)=1;endC=C;C6;imshow(C)imgst=cell(1);%imgst1=I1169;for i=1:19 imgsti=I1order(i)+1;endleftimg=I130;A=;%USE(95)=1;start=30;pra=5;for i=1:209 if USE(i)=0 if (fs(i,1)=fs(start,1) & abs(fs(i,2)-fs(start,2)=pra | fs2(i,1)=fs2(start,1) & abs(fs2(i,2)-fs2(start,2)=pra) A=A i; end endendtemp=zeros(length(A),1);f=zeros(length(A),1);order=;order(1)=30; num=1;for num=1:18for i=1:length(A) if(f(i)=1) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(I1A(i)(:,1); temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendtt1 j1=min(temp);%temp(j1)=99999;order(length(order)+1)=j1;f(order(length(order)=1;leftimg=I1A(order(length(order);endorderC7=I130;USE(30)=1;for i=2:19 C7=C7,I1A(order(i); A(order(i) USE(A(order(i)=1;endC=C;C7;imshow(C)imgst=cell(1);imgst1=I130;for i=2:19 imgsti=I1order(i);endleftimg=I1209;A=;USE(8)=1;USE(209)=1;start=8;pra=3;for i=1:209 if USE(i)=0 if (fs(i,1)=fs(start,1) & abs(fs(i,2)-fs(start,2)=pra | fs2(i,1)=fs2(start,1) & abs(fs2(i,2)-fs2(start,2)19 break; endendfor i=1:19cat2(i)=cat(order(i);endC=;for i=1:19 C=C,I1cat2(i);endimshow(C)附件4:function re,high = bottom(img)t=;high=0;for i=1:size(img,1)t=t,sum(img(i,:);endi=1;while t(i)=0 & i length(t) i=i+1;endwhile t(i)=0 & i length(t) i=i+1;endi1=i;while t(i)=0 & i length(t) i=i+1;endi2=i;while i2-i1 = 20 & i length(t) while t(i)=0 & i length(t) i=i+1;end i1=i; while t(i)=0 & i = length(t) re=0; return; end %出错if abs(i2-i1-25)=2 re=i2; high=i2-i1; return;end %标准字母if abs(i2-i1-36)=1 re=i2; high=i2-i1; return; end %大写字母step=25;for k=1:size(img,2)-step a=; for i=i1:i2 a=a,sum(img(i,k:k+step); end i=1; while a(i)=0 & i 0 i=i-1;end ii2=i; if abs(ii2-ii1-25)=2 re=i1+ii2-1; high=ii2-ii1; return; end endre=0;endp=cats4,cats1,cats7,cats10,cats11;left=133;p1=172 43 67 206 11 158 75 146 84 135 56 19 57 36 17 10 184 153 45 20 195 94 142 89 122 127 106 156 115 177 183 152 23 58 203 72 166 83;p1=p1,82 78 129 201 132 53 126 141 194 88 90 49 73 13 178 125 1 103 116 160 140 2 130 64 139 154 54 39 124 121 176 86 51 161 188 98 204 32;Us=zeros(209,1);Us(left)=1;for i=1:length(p1) Us(p1(i)=1;endimgs=cell(1);imgst=cell(1);for i=1:length(p)imgsi=imgp(i);endp=cats8,cats1,cats7,cats10,cats11;left=20;imgs=cell(1);imgst=cell(1);Us=zeros(209,1);for i=1:length(p)imgsi=imgp(i);endleftimg=imgleft;temp=zeros(length(p),1);flag=zeros(length(p),1);order=;order(1)=left; num=1;for num=1:18for i=1:length(p) if(flag(i)=1&Us(p(i)=0) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(imgp(i)(:,1); %temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendwhile 1tt ttt=min(temp);C1=imgleft;C=;for i=2:length(order) C1=C1,imgp(order(i);endC1=C1,imgp(ttt);C=C;C1;imshow(C)reply = input(Ready? Y/N Y: , s);if isempty(reply) break;else temp(ttt)=99999;endendUs(ttt)=1;order(length(order)+1)=ttt;flag(order(length(order)=1;leftimg=imgp(order(length(order);endC1=imgleft;C=;re=left;for i=2:19 C1=C1,imgp(order(i); re=re,p(order(i);endreC=C;C1;imshow(C)leftimg=imgleft;temp=zeros(length(p),1);flag=zeros(length(p),1);order=;order(1)=left; num=1;for num=1:18for i=1:length(p) if(flag(i)=1 & Us(p(i)=0) temp(i)=sum(abs(double(leftimg(:,size(leftimg,2) - double(imgp(i)(:,1); %temp(i)=temp(i)+sum(abs(double(imgstnum+1(size(imgstnum+1,1),:) - double(I1A(i)(1,:); else temp(i)=99999; endendwhile 1tt ttt=min(temp);C1=imgleft;C=;for i=2:length(order) C1=C1,imgp(order(i);endC1=C1,imgp(ttt);C=C;C1;imshow(C)reply = input(Ready? Y/N Y: , s);if isempty(reply) break;else temp(ttt)=99999;endendUs(ttt)=1;order(length(order)+1)=ttt;flag(order(length(order)=1;leftimg=imgp(order(length(order);endC1=imgleft;C=;re=left;for i=2:19 C1=C1,imgp(order(i); re=re,p(order(i);Us(p(order(i)=1;endreC=C;C1;imshow(C) p=1:209;left=1;p1=2

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论