2013全国大学生数学建模比赛B题 - 答案(7)

2019-08-29 00:31

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

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

29

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 for i=1:19 for m=1:19

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

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

PercentR2RC(i,m)=SingleCompare(Right(:,i),RightCov(:,m)); end end

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

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

%PercentLC2RC

30

for i=1:19 for m=1:19

PercentLC2RC(i,m)=SingleCompare(LeftCov(:,i),RightCov(:,m)); end end

%PercentL2LC; %PercentL2R; %PercentR2L; %PercentR2RC;

PercentR2L; PercentR2RC; PercentLC2L; PercentLC2RC; for i=1:19

PercentR2L(i,i)=0; PercentR2RC(i,i)=0; PercentLC2L(i,i)=0; PercentLC2RC(i,i)=0; end

%从R2L下手

Sample{1}=PercentR2L; Sample{2}=PercentR2RC; Sample{3}=PercentLC2L; Sample{4}=PercentLC2RC;

flag=zeros(1,19); flagCov=zeros(1,19); flagCov(1)=1; i=1; step=1; Path(1)=1; Num=2;

for s=1:500 if step==1

[result1,index1]=max(Sample{1}(i,:)); [result2,index2]=max(Sample{2}(i,:)); if result1>=result2 disp('r1>r2') pause

31

Path(Num)=index1; flagCov(index1)=1; Sample{1}(i,:)=0; i=index1; step=1; Num=Num+1; else

disp('r1

Path(Num)=index2; flagCov(index2)=1; Sample{2}(i,:)=0; i=index2; step=0; Num=Num+1; end else

[result3,index3]=max(Sample{3}(i,:)); [result4,index4]=max(Sample{4}(i,:)); if result3>=result4 disp('r3>r4') pause

Path(Num)=index3; flagCov(index3)=1; Sample{3}(i,:)=0; i=index3; step=1; Num=Num+1; else

disp('r3

Path(Num)=index4; flagCov(index4)=1; Sample{4}(i,:)=0; i=index4; step=0; Num=Num+1; end end

if sum(flagCov(:)==1)==19 break; end

32

end s

flagCov Path

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

%%%%%%%%%%%%%%%%%%%%%%%%%%第二问中文%%%%%%%%%%%%%%%%%%%%%%%%%

%第二问中文 for i=1:208

str= strcat('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T3\\',fullname(i), '.bmp');

b{i}= imread (str); end

a{1}=imread('C:\\Users\\Aero Fantasia\\Desktop\\Competition\\B1\\T3\\000.bmp'); for i=1:208

a{i+1}=b{i}; end

Top=zeros(1,209); for i=1:209

if sum(a{i}(1,:)==255)==72 Top(i)=0; else

Top(i)=1; end end

Area=zeros(180,209);

for i=1:209

for m=1:180

if find(a{i}(m,:)<255) Area(m,i)=1; end end end

for i=1:209 for m=1:209

Similarity(i,m)=SingleCompare2(Area(:,i),Area(:,m)); end end

33


2013全国大学生数学建模比赛B题 - 答案(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:北京化工大学固体物理期末试题-2010A

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: