function r = qad(p2,nmst)
% r = qad(p2,nmst)
[m,n] = size(p2);
r = zeros(m,n);
for ii = 2:m-1
  for jj = 2:n-1
    if (p2(ii,jj) ~= 0)
      up =0;
      down = 0;
      for iii = max(ii-5,1):ii-1
	if (nmst(iii,jj) ~= 0)
          up = 1;
        end
      end
      for iii = ii+1:min(m,ii+5)
	if (nmst(iii,jj) ~= 0)
          down = 1;
        end
      end
      if (up==1) & (down==1)
        r(ii,jj) = 255;
      end
    end
  end
end
