13年数模B题代码.docx
- 文档编号:4508917
- 上传时间:2022-12-01
- 格式:DOCX
- 页数:36
- 大小:881.84KB
13年数模B题代码.docx
《13年数模B题代码.docx》由会员分享,可在线阅读,更多相关《13年数模B题代码.docx(36页珍藏版)》请在冰豆网上搜索。
13年数模B题代码
附件1代码:
I1=cell
(1);I2=cell
(1);
fori=1:
10
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件1\00',num2str(i-1),'.bmp']);
end
fori=11:
19
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件1\0',num2str(i-1),'.bmp']);
end
fortemp=1:
size(I1,2)
fori=1:
size(I1{temp},1)
forj=1:
size(I1{temp},2)
if(I1{temp}(i,j)~=255)
I2{temp}(i,j)=0;
else
I2{temp}(i,j)=1;
end
end
end
end
start=0;
fori=1:
size(I2,2)
n=0;
forj=1:
size(I2{i},1)
if(I2{i}(j,1)==1)
n=n+1;
end
end
if(n==size(I2{i},1))
start=i;
break;
end
end
start1=start;
f=zeros(size(I2,2),1);f(start)=1;ornum=1;order(ornum)=start1;
fort=1:
size(I2,2)-1
fori=1:
size(I2,2)
if(f(i)~=1)
temp(i)=0;
forj=1:
size(I2{start},1)
temp(i)=temp(i)+abs(I2{start}(j,size(I2{start},2))-I2{i}(j,1));
end
else
temp(i)=1000000;
end
end
[ttorder(ornum)]=min(temp);
f(order(ornum))=1;start=order(ornum);ornum=ornum+1;
end
order
I1=cell
(1);
fori=0:
18
I1{1,i+1}=imread(sprintf('C:
\\DocumentsandSettings\\Administrator\\桌面\\all2013\\cumcm2013problems\\B\\附件1\\%03d.bmp',i));
end
A=[]
fori=1:
19
A=[A,I1{seq(i)}];
end
imshow(A)
附件2:
I1=cell
(1);I2=cell
(1);
fori=1:
10
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件2\00',num2str(i-1),'.bmp']);
end
fori=11:
19
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件2\0',num2str(i-1),'.bmp']);
end
fortemp=1:
size(I1,2)
fori=1:
size(I1{temp},1)
forj=1:
size(I1{temp},2)
if(I1{temp}(i,j)~=255)
I2{temp}(i,j)=0;
else
I2{temp}(i,j)=1;
end
end
end
end
start=0;
fori=1:
size(I2,2)
n=0;
forj=1:
size(I2{i},1)
if(I2{i}(j,1)==1)
n=n+1;
end
end
if(n==size(I2{i},1))
start=i;
break;
end
end
start1=start
f=zeros(size(I2,2),1);f(start)=1;ornum=1;order(ornum)=start1;
fort=1:
size(I2,2)-1
fori=1:
size(I2,2)
if(f(i)~=1)
temp(i)=0;
forj=1:
size(I2{start},1)
temp(i)=temp(i)+abs(I2{start}(j,size(I2{start},2))-I2{i}(j,1));
end
else
temp(i)=1000000;
end
end
[torder(ornum)]=min(temp);
f(order(ornum))=1;start=order(ornum);ornum=ornum+1;
end
order
I1=cell
(1);
fori=0:
18
I1{1,i+1}=imread(sprintf('C:
\\DocumentsandSettings\\Administrator\\桌面\\all2013\\cumcm2013problems\\B\\附件2\\%03d.bmp',i));
end
A=[]
fori=1:
19
A=[A,I1{seq(i)}];
end
imshow(A)
附件3:
I1=cell
(1);I2=cell
(1);
fori=1:
10
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件3\00',num2str(i-1),'.bmp']);
end
fori=11:
100
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件3\0',num2str(i-1),'.bmp']);
end
fori=101:
209
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件3\',num2str(i-1),'.bmp']);
end
fortemp=1:
size(I1,2)
fori=1:
size(I1{temp},1)
forj=1:
size(I1{temp},2)
if(I1{temp}(i,j)<225)
I2{temp}(i,j)=0;
else
I2{temp}(i,j)=1;
end
end
end
end
start=0;
fori=1:
size(I2,2)
temp=zeros(size(I2{i},1),1);
fork=1:
size(I2{i},1)
forj=1:
size(I2{i},2)
if(I2{i}(k,j)==0)
temp(k)=temp(k)+1;
end
end
end
wh(i)=0;
fork=1:
size(I2{i},1)
if(temp(k)>=1)
break;
else
wh(i)=wh(i)+1;
end
end
end
ttemp=[];
fori=1:
size(wh,2)
if(wh(i)>35&&wh(i)<50)
ttemp=[ttemp,i];
end
end
ttemp
I3=cell
(1);
fori=1:
19
fork=1:
size(I2{i},1)
forj=1:
size(I2{i},2)
I3{i}(k,j)=I2{ttemp(i)}(k,j);
end
end
end
start=0;
fori=1:
size(I3,2)
n=0;
forj=1:
size(I3{i},1)
if(I3{i}(j,1)==1)
n=n+1;
end
end
if(n==size(I3{i},1))
start=i;
break;
end
end
temp=zeros(size(I3,2),1);
flag=zeros(size(I3,2),1);flag(start)=1;ornum=1;order(ornum)=start;
fort=1:
size(I3,2)-1
fori=1:
size(I3,2)
if(flag(i)~=1)
temp(i)=0;
forj=1:
size(I3{start},1)
temp(i)=temp(i)+abs(I3{start}(j,size(I3{start},2))-I3{i}(j,1));
end
else
temp(i)=1000000;
end
end
ornum=ornum+1;
[ttorder(ornum)]=min(temp);
flag(order(ornum))=1;start=order(ornum);
end
fori=1:
19
ab(i)=ttemp(order(i));
end
ab
I1=cell
(1);I2=cell
(1);
fori=1:
10
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件3\00',num2str(i-1),'.bmp']);
end
fori=11:
100
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件3\0',num2str(i-1),'.bmp']);
end
fori=101:
209
I1{1,i}=imread(['C:
\Users\Administrator\Desktop\all2013\cumcm2013problems\B\附件3\',num2str(i-1),'.bmp']);
end
fortemp=1:
size(I1,2)
fori=1:
size(I1{temp},1)
forj=1:
size(I1{temp},2)
if(I1{temp}(i,j)<225)
I2{temp}(i,j)=0;
else
I2{temp}(i,j)=1;
end
end
end
end
start=0;
fori=1:
size(I2,2)
temp=zeros(size(I2{i},2),1);
fork=1:
size(I2{i},1)
forj=1:
size(I2{i},2)
if(I2{i}(k,j)==0)
temp(j)=temp(j)+1;
end
end
end
wh(i)=0;
fork=1:
size(I2{i},2)
if(temp(k)>=1)
break;
else
wh(i)=wh(i)+1;
end
end
end
ttemp=[];
fori=1:
size(wh,2)
if(wh(i)>10)
ttemp=[ttemp,i];
end
end
ttemp
imgs=cell
(1);
imgst=cell
(1);
fori=1:
19
imgst{i}=I1{ab(i)};
end
A=[7202137465364686970737980848697100117127132163164171178203];
fori=1:
length(A)
imgs{i}=I1{A(i)};
end
leftimg=I1{62};
temp=zeros(length(A),1);
f=zeros(length(A),1);
order=[];order
(1)=62;num=1;
fornum=1:
18
fori=1:
length(A)
if(f(i)~=1)
temp(i)=sum(abs(double(leftimg(:
size(leftimg,2)))-double(I1{A(i)}(:
1))));
temp(i)=temp(i)+sum(abs(double(imgst{num+1}(size(imgst{num+1},1),:
))-double(I1{A(i)}(1,:
))));
else
temp(i)=99999;
end
end
[ttorder(length(order)+1)]=min(temp);
f(order(length(order)))=1;
leftimg=I1{A(order(length(order)))};
end
C1=[I1{62}];USE(62)=1;
fori=2:
19
C1=[C1,I1{A(order(i))}];
A(order(i))
USE(A(order(i)))=1;
end
C=[C;C1];
imshow(C)
imgst=cell
(1);imgst{1}=I1{62};
fori=2:
19
imgst{i}=I1{A(order(i))};
end
A=[213192427313240425152637477838788101108116121129143148160161170177180192196204];
fori=1:
length(A)
imgs{i}=I1{A(i)};
end
leftimg=I1{169};
temp=zeros(length(A),1);
f=zeros(length(A),1);
order=[];order
(1)=169;num=1;
fornum=1:
18
fori=1:
length(A)
if(f(i)~=1)
temp(i)=sum(abs(double(leftimg(:
size(leftimg,2)))-double(I1{A(i)}(:
1))));
temp(i)=temp(i)+sum(abs(double(imgst{num+1}(size(imgst{num+1},1),:
))-double(I1{A(i)}(1,:
))));
else
temp(i)=99999;
end
end
[tt1j1]=min(temp);%temp(j1)=99999;
order(length(order)+1)=j1;
f(order(length(order)))=1;
leftimg=I1{A(order(length(order)))};
end
order
order(19)=3;order(18)=17;
C2=[I1{169}];USE(169)=1;
fori=2:
19
C2=[C2,I1{A(order(i))}];
A(order(i))
USE(A(order(i)))=1;
end
C=[C;C2];
imshow(C)
leftimg=I1{39};A=[]
start=39;pra=2;
fori=1:
209
ifUSE(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=[Ai];
end
end
end
temp=zeros(length(A),1);
f=zeros(length(A),1);
order=[];order
(1)=39;num=1;
fornum=1:
18
fori=1:
length(A)
if(f(i)~=1)
temp(i)=sum(abs(double(leftimg(:
size(leftimg,2)))-double(I1{A(i)}(:
1))));
temp(i)=temp(i)+sum(abs(double(imgst{num+1}(size(imgst{num+1},1),:
))-double(I1{A(i)}(1,:
))));
else
temp(i)=99999;
end
end
[tt1j1]=min(temp);%temp(j1)=99999;
order(length(order)+1)=j1;
f(order(length(order)))=1;
leftimg=I1{A(order(length(order)))};
end
order
C3=[I1{39}];USE(39)=1;
fori=2:
19
C3=[C3,I1{A(order(i))}];
A(order(i))
USE(A(order(i)))=1;
end
C=[C;C3];
imshow(C)
leftimg=I1{15};A=[]
start=15;pra=2;
fori=1:
209
ifUSE(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)&i~=177
A=[Ai];
end
end
end
temp=zeros(length(A),1);
f=zeros(length(A),1);
order=[];order
(1)=15;num=1;
start=15;
fornum=1:
18
fori=1:
length(A)
if(f(i)~=1)
if0==fs(start,1)&0==fs(A(i),1)&fs(A(i),2)>fs(start,2)+2
temp(i)=99999;
else
temp(i)=sum(abs(double(leftimg(:
size(leftimg,2)))-double(I1{A(i)}(:
1))));
temp(i)=temp(i)+sum(abs(double(imgst{num+1}(size(imgst{num+1},1),:
))-double(I1{A(i)}(1,:
))));
end
else
temp(i)=99999;
end
end
[tt1j1]=min(temp);%temp(j1)=99999;
order(length(order)+1)=j1;
start=A(j1);
f(order(length(order)))=1;
leftimg=I1{A(order(length(order)))};
end
order
C4=[I1{15}];USE(15)=1;
fori=2:
19
C4=[C4,I1{A(order(i))}];
A(order(i))
USE(A(order(i)))=1;
end
C=[C;C4];
imshow(C)
imgst=cell
(1);%imgst{1}=I1{169};
fori=1:
19
imgst{i}=I1{order(i)+1};
end
leftimg=I1{95};A=[];%USE(95)=1;
start=95;pra=2;
fori=1:
209
ifUSE(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=[Ai];
end
end
end
temp=zeros(length(A),1);
f=zeros(length(A),1);
order=[];order
(1)=95;num=1;
fornum=1:
18
fori=1:
length(A)
if(f(i)~=1)
temp(i)=sum(abs(double(leftimg(:
size(leftimg,2)))-double(I1{A(i)}(:
1))));
temp(i)=temp(i)+sum(abs(double(imgst{num+1}(size(imgst{num+1},1),:
))-double(I1{A(i)}(1,:
))));
else
temp(i)=99999;
end
end
[tt1j1]=min(temp);%temp(j1)=99999;
order(length(order)+1)=j1;
f(order(length(order)))=1;
leftimg=I1{A(order(length(order)))};
end
order
C5=[I1{95}];USE(95)=1;
fori=2:
19
if(i~=6)
C5=[C5,I1{A(order(i))}];
A(order(i))
USE(A(order(i)))=1;
else
C5=[C5,I1{48}];
USE(48)=1;
48
end
end
C=[C;C5];
imshow(C)
imgst=cell
(1);imgst{1}=I1{95};
fori=2:
19
%order(i)
%A(order(i))
imgst{i}=I1{A(order(i))};
end
imgst{6}=I1{48};
leftimg=I1{126};A=[];
start=126;pra=2;
fori=1:
209
ifUSE(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=[Ai];
end
end
end
temp=zeros(length(A),1);
f=zeros(length(A),1);
order=[];order
(1)=126;num=1;
fornum=1:
18
fori=1:
length(A)
if(f(i)~=1)
temp(i)=sum(abs(double(leftimg(:
size(leftimg,2)))-double(I1{A(i)}(:
1))));
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 13 数模 代码
![提示](https://static.bdocx.com/images/bang_tan.gif)