1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| function pos =localise(x)
x=imdilate(x,ones(1,64));
seuil=1;
maskig=sum(x)>=seuil;
detlig=zeros(size(maskig));
detlig(2:end) =maskig(2:end)-maskig(1:end-1);
detlig(2:end) =maskig(2:end)-maskig(1:end-1);
deblig=find(detlig>0);
finlig=find(detlig<0)-1;
if (length(deblig)~=length(finlig))
disp('erreur dans localise:');
disp('probleme dans la detection des lignes');
end
ptr =1;
for nl=1:length(deblig)
ligne = x(deblig(nl):finlig(nl),:);
maskcol=sum(ligne)>=seuil;
detcol=zeros(size(maskcol));
detcol(2:end)=maskcol(2:end)-maskcol(1:end-1);
debcol=find(detcol>0)-1;
fincol=find(detcol<0);
nchif=length(debcol);
if (nchif~=length(debcol))
disp ('erreur dans localise:');
disp('probleme dans le traitement d''une ligne');
end;
pos(ptr:ptr+nchif-1,:)=...
[deblig (nl)*ones(nchif,1)...
debcol(finlig(nl))*ones(nchif,1) fincol'];ptr=ptr+length(debcol);
end |
Partager