function n=neighbours(X,v);
%n=neighbours(X,v);
%
%Extracts the neighbours(4-connectivity) at location v=(x,y) in
%the image X starting from the right and going clockwise. 
%
%NOTE: It DOESN'T work when applied to a boundary location!
%This is for you to do, if you need it...
% 
%Mats K 000402
[Ny,Nx]=size(X);

if length(v)==2
    coor=(v(1)-1)*Ny+v(2);
else
    coor=v;
end


n(1)=X(coor+Ny);
n(2)=X(coor+1);
n(3)=X(coor-Ny);
n(4)=X(coor-1);

