A photo is a function: brightness at every pixel. Edges are where brightness changes fast, which is exactly where its partial derivatives are large.