function [dx,dy]=sdxy(im);

[m,n]=size(im);

tmp=(im(:,3:n)-im(:,1:n-2))/2;
dx=zeros(m,n);
dx(:,2:n-1)=tmp;
dx(:,1)=dx(:,2);
dx(:,n)=dx(:,n-1);

tmp=(im(3:m,:)-im(1:m-2,:))/2;
dy=zeros(m,n);
dy(2:m-1,:)=tmp;
dy(1,:)=dy(2,:);
dy(m,:)=dy(m-1,:);
