function [edge] = fourNeighbourEdge(bw)

[h, w] = size(bw);

edge = zeros(h, w);
for i = 2:h-1
    for j = 2:w-1
        if (bw(i, j) == 0)
           if (bw(i-1, j) == 1 || bw(i, j-1) == 1 || bw(i+1, j) == 1 || bw(i, j+1) == 1)
                   % uncomment this -> 8 neighbour
                   %|| bw(i-1, j-1) == 1 || bw(i-1, j+1) == 1 || bw(i+1, j-1) == 1 || bw(i+1, j+1) == 1)
              edge(i, j) = 1; 
           end
        end
    end
end

end