function [S]=seg(I);
a=0;
[nbl,nbc]=size(I);
for i=1:nbl
	S(i,1)=a;
	for j=2:nbc
		if(I(i,j)==I(i,j-1))
			then S(i,j)=a;
			else
				a=a+1;
				S(i,j)=a;
		end;
	end;
	a=a+1;
end;
endfunction;
