D=imread('Dirt1.jpg');
Dq=quant(D,1);

%L=freadbin('lenna.256', 256, 256, 'uchar');
%Lq=quant(L,1);

Lq=Dq;

sz=size(Lq);
Ledv=zeros(sz);
Ledh=zeros(sz);

for j=1:sz(1)-1
   for i=1:sz(1)-1
      Ledh(i,j)=Lq(i,j)-Lq(i+1,j);
   end
end

for i=1:sz(1)-1
   for j=1:sz(1)-1
      Ledv(i,j)=Lq(i,j)-Lq(i,j+1);
   end
end

h=find( or(Ledh==-128, Ledh==128) );
v=find( or(Ledv==-128, Ledv==128) );
Ledh(h)=1;
Ledv(v)=1;

Led=or(Ledh, Ledv);
