%compute sum of difference between adjacent pixel values

function diff = comp_diff(x)

diff=0;
for I=1:3
   for J=1:4
      diff=diff+abs(x(I+1,J)-x(I,J))+abs(x(J,I+1)-x(J,I));
   end
end
