function [NeighReturn]=get8NeighCheck2(x,y,Lat,r,c)
%As an alternative to image thresholding algorithms, we design an 
%"edge follower" which will follow the boundaries between 0s (Sea Ice) and
%1s (Melt Ponds). This function returns all eight neighbors of the input
%point that have not yet been visited.
%
%INPUTS
%    x = The x-position which the traverse function currently is located at
%    y = The y-position which the traverse function currently is located at
%  Lat = Level set with 1s and 0s representing melt ponds and sea ice
%    r = Number of rows in Lat (1000 for continuum model data)
%    c = Number of columns in Lat (1000 for continuum model data)
%
%OUTPUTS
% NeighReturn = The array of vertices returned that are connected to the
%               input vertex vert and have not been visited already
%
%
%By: Anthony Cheng (Mar 2015)
%===================================================================

Neigh = [];

%Check the vertex to the below-left
if y-1 <= 0 
else
   if x-1 <= 0
   else
       if Lat(y-1,x-1) == 2
           Neigh = cat(1,Neigh,[x-1,y-1]);
       else
       end
   end
end

%Check the vertex to the below
if y-1 <= 0 
else
   if Lat(y-1,x) == 2
        Neigh = cat(1,Neigh,[x,y-1]);
   else
   end
end

%Check the vertex to the below-right
if y-1 <= 0 
else
   if x+1 > c
   else
       if Lat(y-1,x+1) == 2
            Neigh = cat(1,Neigh,[x+1,y-1]);
       else
       end    
   end
end

%Check the vertex to the left
if x-1 <= 0
else
   if Lat(y,x-1) == 2
        Neigh = cat(1,Neigh,[x-1,y]);
   else
   end
end

%Check the vertex to the right
if x+1 > c
else
   if Lat(y,x+1) == 2
        Neigh = cat(1,Neigh,[x+1,y]);
   else
   end
end

%Check the vertex above
if y+1 > r
else
   if Lat(y+1,x) == 2
       Neigh = cat(1,Neigh,[x,y+1]);
   else
   end
end

%Check the vertex above-left
if y+1 > r
else
   if x-1 <= 0
   else
       if Lat(y+1,x-1) == 2
          Neigh = cat(1,Neigh,[x-1,y+1]);
       else
       end
   end
end

%Check the vertex above-right
if y+1 > r
else
   if x+1 > c
   else
       if Lat(y+1,x+1) == 2
            Neigh = cat(1,Neigh,[x+1,y+1]);
       else
       end
   end
end

NeighReturn = Neigh;

end