function s = cv_Canny_nonmax_sup(Es,Eo)
%
[rows,cols] = size(Es);
s = Es;
offset = [0,1;0,-1;-1,1;1,-1;-1,0;1,0;-1,-1;1,1];

for r = 2:rows-1
   for c = 2:cols-1
      if Es(r,c)>0
         angle = Eo(r,c);
         if angle >= pi
            angle = angle-pi;
         end
         if angle <pi/8
            index = 1;
         elseif angle < 3*pi/8
            index = 3;
         elseif angle < 5*pi/8
            index = 5;
         else
            index = 7;
         end
         val = Es(r,c);
         val1 = Es(r+offset(index,1),c+offset(index,2));
         val2 = Es(r+offset(index+1,1),c+offset(index+1,2));
         if (val<val1) | (val<val2)
            s(r,c) = 0;
         end
      end
   end
end
