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

Lesson 1 of the Edge Detection unit. 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 plus-or-minus 0.03 of noise and the first derivative holds its position while the zero-crossing slides half a pixel off the edge, which is why Canny is built on the first derivative and not the second.

More in edges and features