标签:highlight end ima class atl dir 5* show 图像
Photo1_1:
clear;clc; path=‘E:\B\附件1\‘; files=dir(‘E:\B\附件1\*.bmp‘); % objdir=‘E:\B\附件1\‘; % bgfile=[objdir,[‘00‘ int2str(i)],‘.bmp‘]; % lengthf=length(files); % for i=1:lengthf % img=imread(strcat(‘E:\B\附件1\‘,files(i).name)); % imshow(img); % end % bg=imread([path,files(1).name]); % imshow(bg); % imageinfo([path,files(1).name]) xsmat=ones(19,19); for i=1:19 imi=imread([path,files(i).name]); [mrow,mcol]=size(imi); for j=1:19 imj=imread([path,files(j).name]); timi=im2double(imi); timj=im2double(imj); xssum=sum(abs(timi(:,mcol)-timj(:,1)));%计算图像i和图像j的相似度。 xsmat(i,j)=xssum; end end first=0;last=0; for i=1:19 img=imread([path,files(i).name]); [ro,co]=size(img); tot=0; for j=1:ro if(img(j,1)==255) tot=tot+1; end end if tot==ro first=i; break; end end que=[]; que=[que first]; flag=1; pos=1; tf=first; while(flag==1) t=255*255*254; tp=0; for i=1:19 if i~=tf if t>xsmat(tf,i) t=xsmat(tf,i); tp=i; end end end tf=tp; pos=pos+1; que=[que tp]; if pos==19 flag=0; end end tim=[]; for i=1:19 im=imread([path files(que(i)).name]); tim=[tim im]; end imshow(tim);
Photo1_2:
clear;clc; path=‘E:\B\附件2\‘; files=dir(‘E:\B\附件2\*.bmp‘); xsmat=ones(19,19); for i=1:19 imi=imread([path,files(i).name]); [mrow,mcol]=size(imi); for j=1:19 imj=imread([path,files(j).name]); timi=im2double(imi); timj=im2double(imj); xssum=sum((timi(:,mcol)-timj(:,1)).^2);%计算图像i和图像j的相似度。 xsmat(i,j)=xssum; end end first=0;last=0; for i=1:19 img=imread([path,files(i).name]); [ro,co]=size(img); tot=0; for j=1:ro if(img(j,1)==255) tot=tot+1; end end if tot==ro first=i; break; end end que=[] que=[que first]; flag=1; pos=1; tf=first; while(flag==1) t=255*255*254; tp=0; for i=1:19 if i~=tf if t>xsmat(tf,i) t=xsmat(tf,i); tp=i; end end end tf=tp; pos=pos+1; que=[que tp]; if pos==19 flag=0; end end tim=[]; for i=1:19 im=imread([path files(que(i)).name]); tim=[tim im]; end imshow(tim);
标签:highlight end ima class atl dir 5* show 图像
原文地址:https://www.cnblogs.com/zxhyxiao/p/9544132.html