function c = locmindir(f,i1,j1,angle1)
%
% locmindir: reports if pixel is a local intensity minimum in direction
%            angle1
% On input:
%     f: 2D intensity image
%    i1: pixel row
%    j1: pixel col
%    angle1: direction of interest
% On output:
%    c: 1 if yes
%       0 if not
% Call:
%     c = locmindir(f,i1,j1,angle1)
%

c = 1;     % Assume true

angle = angle1;
if angle>pi
  angle = angle-pi;
end;
v2 = f(i1,j1);
if (angle<(pi/8)) | (angle>((3*pi/4)+(pi/8)))
  v1 = f(i1,j1-1); v3 = f(i1,j1+1);
elseif (angle>pi/8) & (angle<(3*pi/8))
  v1 = f(i1+1,j1-1); v3 = f(i1-1,j1+1);
elseif (angle>3*pi/8) & (angle<(5*pi/8))
  v1 = f(i1+1,j1); v3 = f(i1-1,j1);
elseif (angle>5*pi/8) & (angle<(7*pi/8))
  v1 = f(i1+1,j1+1); v3 = f(i1-1,j1-1);
end;

if v1<v2 | v3<v2
  c = 0;
end;
