Simple edge detection (NFHHAI, p. 80)
S(I,J) = \frac{{\color{Red} I(I-1,J)}-{\color{Red} (I(I+1,J)}}{2}
Complex edge detection with diagonals (NFHHAI, p. 80, same page)
S(I,J) = \sqrt{(\frac{I(I-1,J)-(I(I+1,J)}{2})^2+(\frac{I(I,J-1)-I(I,J+1)}{2})^2}
[NFHHAI]: Richard Forsyth, Chris Naylor: The Hitch-Hiker's Guide to Artificial Intelligence, IBM PC Basic Version, 1986, Chapman and Hall Ltd/Methuen London Ltd, also available under https://archive.org/details/forsyth-naylor-hitchhikers-guide-to-ai-pc-basic/page/80/mode/2up?view=theater