  function B = Edges(P)
% P is a jpeg file
% B is the corresponding uint8 Rate-Of-Change array 
% based on maximum discrepancy. Basically, B(i,j) measures the difference
% between the (i,j) pixel of P and its eight neighbors.

  A = rgb2gray(imread(P));
  [m,n] = size(A);
  B = uint8(zeros(m,n));
  for i=2:m-1
     for j = 2:n-1
        % Compute the maximum difference between pixel A(i,j) and
        % its eight pixel neighbors. Assign this value to B(i,j)
        C = A(i-1:i+1,j-1:j+1);
        C = C - C(2,2);
        C = abs(C);
        colMaxes = max(C);
        TheMax = max(colMaxes);
        B(i,j) = TheMax;
        %Shortcut:  B(i,j) = max( max( abs( A(i-1:i+1,j-1:j+1) - A(i,j))));
     end
  end
 Snapshot = B(100:110,200:210)


