c语言的源文件
,首先批量读取文件,存储为(II) II=cell(1,19); for i=1:19 imageName=strcat('C:\Documents and Settings\MathLehrer\桌面\碎纸片\附件1\',num2str(i-1),'.bmp'); II{i} = imread(imageName); end 2、将每个图像二值化(采用OTSU算法),存储为(JJ) JJ=cell(1,19); for i=1:19 th=graythresh(II{i}); JJ{i}=im2bw(II{i},th); end 3、提取每个二值化图像后即(JJ)的边界,将边界构成边界矩阵 Ji=[JJ{1}(:,1) JJ{1}(:,72) JJ{2}(:,1) JJ{2}(:,72) JJ{3}(:,1) JJ{3}(:,72) JJ{4}(:,1) JJ{4}(:,72) JJ{5}(:,1) JJ{5}(:,72) JJ{6}(:,1) JJ{6}(:,72) JJ{7}(:,1) JJ{7}(:,72) JJ{8}(:,1) JJ{8}(:,72) JJ{9}(:,1) JJ{9}(:,72) JJ{10}(:,1) JJ{10}(:,72)]; Ji1=[JJ{11}(:,1) JJ{11}(:,72) JJ{12}(:,1) JJ{12}(:,72) JJ{13}(:,1) JJ{13}(:,72) JJ{14}(:,1) JJ{14}(:,72) JJ{15}(:,1) JJ{15}(:,72) JJ{16}(:,1) JJ{16}(:,72) JJ{17}(:,1) JJ{17}(:,72) JJ{18}(:,1) JJ{18}(:,72) JJ{19}(:,1) JJ{19}(:,72)]; Jii=[Ji Ji1]; 4、采用边界配对法 边界配对原则: 像数相同数目最大配对原则: function c=cout0(a,b) t=size(a);c=0; for i=1:t if(abs(a(i)==b(i))) c=c+1; end end 例:c=zeros(1,19);