2013年全国数模B题

导读:附件5的复原图片(正面)27附件5的复原图片(反面)28附录matlab代码%%%%%%%%%%%%%%%%%%%%%%匹配度%%%%%%%%%%%%%%%%%%%%%%%%%functionResultLine=sortTeam(R,R2L)Indexs=R;Result=zeros(length(R));fori=1:length(R)form=1:le

2013年全国数模B题

附件5的复原图片(正面)

27

附件5的复原图片(反面)

28

附录matlab代码

%%%%%%%%%%%%%%%%%%%%%%匹配度%%%%%%%%%%%%%%%%%%%%%%%%% function ResultLine=sortTeam(R,R2L) Indexs=R;

Result=zeros(length(R)); for i=1:length(R) for m=1:length(R)

PercentCom(i,m)=R2L(R(i),R(m)); end end

PercentCom;

flag=zeros(1,length(R)); Root=1;

ResultLine=[1]; for i=1:length(R)

[result,index]=max(PercentCom(Root,:)); flag(Root)=1;

PercentCom(Root,:)=0; PercentCom(:,Root)=0; flag(index)=1;

ResultLine=[ResultLine index]; Root=index;

if sum(flag(:)==1)==length(R) break; end end

for i=1:length(R)

ResultLine(i)=R(ResultLine(i)); end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%第一问的算法流程%%%%%%%%%%%%%

a{1}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\0.bmp'); a{2}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\1.bmp'); a{3}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\2.bmp'); a{4}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\3.bmp');

29

a{5}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\4.bmp'); a{6}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\5.bmp'); a{7}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\6.bmp'); a{8}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\7.bmp'); a{9}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\8.bmp'); a{10}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\9.bmp'); a{11}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\10.bmp'); a{12}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\11.bmp'); a{13}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\12.bmp'); a{14}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\13.bmp'); a{15}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\14.bmp'); a{16}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\15.bmp'); a{17}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\16.bmp'); a{18}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\17.bmp'); a{19}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T1\\18.bmp');

%取边缘 for i=1:19 demo=[];

demo(:,1)=a{i}(:,1);

demo(:,2)=a{i}(:,length(a{i}(1,:))); T{i}=demo; end

%二值化 for i=1:19 Com=[]; for m=1:2

for n=1:1980

if T{i}(n,m)==255 Com(n,m)=0; else

Com(n,m)=1; end end end

C{i}=Com; end

Left=[]; for i=1:19

Left=[Left,C{i}(:,1)]; end

30

Right=[]; for i=1:19

Right=[Right,C{i}(:,2)]; end

LeftCov=[]; for i=1:19

LeftCov=[LeftCov,C{i}(:,1)]; end

for i=1:19

for m=1:1980

demo(1981-m,i)=LeftCov(m,i); end end

LeftCov=demo;

RightCov=[]; for i=1:19

RightCov=[RightCov,C{i}(:,2)]; end

for i=1:19

for m=1:1980

demo(1981-m,i)=RightCov(m,i); end end

RightCov=demo;

%PercentL2LC %for i=1:19 % for m=i:19

% PercentL2LC(i,m)=SingleCompare(Left(:,i),LeftCov(:,m)); %end %end

%PercentL2R %for i=1:19 %for m=i:19

% PercentL2R(i,m)=SingleCompare(Left(:,i),Right(:,m)); % end %end

%PercentR2L

31

五星文库wxphp.com包含总结汇报、考试资料、党团工作、外语学习、教学教材、旅游景点、行业论文、文档下载、IT计算机以及2013年全国数模B题等内容。

本文共8页1<<5678