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