◂ the notebook

phycists.desmondbrown.me

Other projections⟨dev|Desmond⟩⟨ee|Desmond⟩⟨academic|Desmond⟩

No. 1026 February 2026.
Image processing from first principles

Edges as gradients: finite differences on real images

An edge is where brightness changes fast, so it is a large gradient. I take it from first principles: forward differences for the two partial derivatives, the magnitude, and a threshold at a tenth of the largest value. No library does the maths.

Ix = I(i, j+1) − I(i, j),Iy = I(i+1, j) − I(i, j)

|∇I| = √(Ix² + Iy²), edge where |∇I| ≥ 0.1 max|∇I|

A bamboo specimen under the metallurgical microscope, in greyscaleThe same micrograph after the finite-difference edge detector

A bamboo specimen under the microscope in the grain-boundary lab, and the same photo through my detector with its own threshold. The specimen’s edge comes through; so does its texture.

what I don’t understand yet

Why the texture comes out as edges. Differences amplify noise, and this version never smooths. A Gaussian blur before differencing, the first step of Canny’s method, is the next version.