function boolean = checkNeighborhood(N, d)
%return true if the 3x3 neighborhood contains a pixels in the 
%d direction ('theta') describe a maximum (a,b,c, where a < b > c).

boolean = 0;
a = N(2,2);
if N(2,2) == 0
	return;
end

%horizontal edges
if ((d > -1/4*pi && d < 1/4*pi) || (d > 3/4*pi && d < 1.25*pi)) ...
	&& N(2,1) < a && N(2,3) < a
    boolean = 1;
%vertical edges
elseif ((d > 1/4*pi && d < 3/4*pi) || (d > -3/4*pi && d < -1/4*pi)) ...
	&& N(3,2) < a && N(1,2) < a
    boolean = 1;
%diagonal edges
elseif ((d > 0 && d < 1/2*pi) || (d > -pi && d < -1/2*pi)) ...
	&& N(1,1) < a && N(3,3) < a
    boolean = 1;
elseif ((d > 1/2*pi && d < pi) || (d > -1/2*pi && d < 0)) ...
	&& N(1,3) < a && N(3,1) < a
    boolean = 1;
end
