www.pudn.com > codebar.rar > ImageEdgePoint.m
%边界点的读取
%
function [stlist,endlist,Count,vpixel,hpixel] = ImageEdgePoint(I,height,width)
stlist = zeros(height,1); %每一行的起点
endlist = zeros(height,1);
vpixel = zeros(height,1);
hpixel = zeros(width,1);
stcout = 1;
endcout = 0;
for i=1:height
newline = true;
endflag = false;
for j=1:width
if(j > 1)
if((I(i,j) == 0) && (I(i,j-1) == 1))
endlist(i,1) = j;
endflag = true;
%若前面一点为白,后面一点为黑,则认为是最后一点,通过不断的迭代,直到本行完了为止
end
end
if(I(i,j) == 1) %统计白点
if(newline == true)
stlist(i,1) = j;
stcout = stcout+1;
newline = false;
end
vpixel(i,1) = vpixel(i,1) + 1;%水平投影
hpixel(j,1) = hpixel(j,1) + 1;%PixelH[j] += 1;%垂直投影
end
end
if(endflag == true)
endcout = endcout+1;
end
end
Count=[stcout endcout];
%stcout = stcount;
%endcout = endcount;