function [a,ioff,joff] = lext(al,l)
%
% lext: slice one gray level in an image into a window
% On input:
%     al:
%     l:
% On output:
%     a:
%     ioff:
%     joff:
% Call:
%     [a,ioff,joff] = lext(al,l)
%

a = [];
a3 = [];
[m,n] = size(al);
a1 = al==l*ones(m,n);
a2 = a1.*al;
ioff = 0; nonz = 0;
for i1 = 1:m
  if sum(a2(i1,:)) ~= 0
    a3 = [a3 ; a2(i1,:)];
	nonz = 1;
  else
    if nonz == 0
	  ioff = ioff+1;
	end
  end
end
joff = 0; nonz = 0;
for j1 = 1:n
  if sum(a3(:,j1)) ~= 0
    a = [a ; a3(:,j1)'];
	nonz = 1;
  else
    if nonz == 0
	  joff = joff+1;
	end
  end
end
a = a';
