An edge, and its two derivatives

A single scanline across an edge, in one of three profiles: step, ramp or roof, drawn twice: as the row of grey pixels it would be in a photograph, and as a curve with its first and second derivatives underneath. An edge is a peak in the first derivative and a sign change in the second.

Try this

Turn the noise up with smoothing at zero and count the zero-crossings. One edge produces dozens. Then bring smoothing back.

Where this lab comes from

What Is an Edge? Step, Ramp and Roof, and the Two Derivatives That Find Them

An edge is a peak in the first derivative and a sign change in the second. Worked by hand on nine pixels: the peak lands on column 4 and the second difference is exactly zero there. Add noise of at most 0.03 and the zero-crossing moves by 0.05 px, which is small; the real cost of the second derivative is the sign changes noise makes on its own, with no size attached to threshold, which is why Canny is built on the first derivative.

More in edges and features