C11 · Change and measure
Derivatives, edges and sharpening
An edge is a change in the signal. Distinguish measuring that change from enhancing detail and finding a whole object.
Background if needed
Theory
A derivative asks how things change
Along a flat row, neighboring differences are small. A dark-to-light transition gives a positive derivative; the reverse gives a negative one. Derivatives retain their sign: a grayscale photograph alone cannot convey the values without a scale.
Sobel averages across the measured direction and takes differences along it. Roberts, Prewitt and Scharr use other neighborhoods or weights. The magnitude of two derivatives measures strength; their direction is normal to the edge. Derivatives amplify noise, motivating smoothing first.
Where brightness rises or falls
Select a dark-to-light transition, then the reverse. The line marks the cross-section and the graph shows the change sign. Compare sharpening separately below.
Exact values are in the point inspector
Grayscale 0…1: black to white.
- Display the x derivative
Exact values are in the point inspector
Blue − · white 0 · red +; scale -2…2
Inspect the selected point
What the plot shows
The image line marks this same row. Select a higher or lower point to move the cross-section; compare values at the same column.
- Input
- Result
- Selected column: 8
A flat area has near-zero derivative. When sharpening, look for overshoots near edges, not newly measured detail.
Parameters and details
Sobel uses divisor 8 and repeated borders. Sharpening = input + amount × (input − smoothed); negative values are retained.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Canny is a sequence, not one threshold
Smoothing reduces noise. Gradient magnitude produces broad response bands. Non-maximum suppression keeps points no weaker than their neighbors along the gradient direction. This teaching implementation quantizes direction into four possibilities.
The upper threshold finds strong edges. The lower permits continuation through weaker points: only 8-connected chains reaching a strong point survive. If the lower threshold exceeds the upper one, this implementation uses the lower as the effective upper. No stage identifies the object beyond the line.
From a broad edge to a thin one
Follow the stages in order. The left image is the selected step's input and the right is its output. Select an edge: the middle shows the calculation or decision that produced this point.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
A weak response survives only if connected to a strong one. A thin line is not yet a segmented object.
Parameters and details
Four computed stages: 3×3 binomial smoothing, Sobel, four-direction non-maximum suppression and 8-connected hysteresis. This is a discrete educational Canny variant. Effective thresholds: 0.04 and 0.1; the upper threshold cannot be below the lower one.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Sharpening boosts a residual, not ground truth
Unsharp masking subtracts a blurred image from the input and adds part of that detail back. Positive and negative edge overshoots look sharper but become halos at high gain. The profile shows them before display clipping.
The Laplacian measures second-order change; LoG smooths first, while DoG approximates a related multiscale operation. A zero crossing is an edge candidate, not proof. Unlike residual enhancement, deconvolution begins with a model of how the image was blurred; that leads to inverse problems.
Where a halo comes from
Select a point beside a sharp edge. Increase the gain and watch the profile exceed the original values. This is a halo, not a recovered measurement.
Exact values are in the point inspector
Grayscale 0…1: black to white.
- Input minus smoothed
- Add the amplified detail
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
The image line marks this same row. Select a higher or lower point to move the cross-section; compare values at the same column.
- Input
- Result
- Selected column: 8
A flat area has near-zero derivative. When sharpening, look for overshoots near edges, not newly measured detail.
Parameters and details
Sobel uses divisor 8 and repeated borders. Sharpening = input + amount × (input − smoothed); negative values are retained.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Practice
Test the idea under another condition. Follow the task above the images; point inspection helps explain the result. This exploration is not scored.
Continue a weak edge without accepting every response
Start with a high upper threshold. Lower it until a strong edge appears, then change only the lower threshold. In the class map, find a connected weak point and a rejected weak point.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
The lower threshold permits continuation; it does not turn an isolated weak response into a strong one. Check the values at one coordinate.
Parameters and details
Four computed stages: 3×3 binomial smoothing, Sobel, four-direction non-maximum suppression and 8-connected hysteresis. This is a discrete educational Canny variant. Effective thresholds: 0.08 and 0.25; the upper threshold cannot be below the lower one.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Games
Test your explanation
Question 1 of 5
What does a negative x derivative mean?
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Color denotes a category, not magnitude.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Blue − · white 0 · red +; scale -2…2
Choose one answer. It is checked immediately.
Limitations and references
Limits of this example
Live calculations: Sobel, unsharp masking and four-direction educational Canny. Other operators are discussed comparatively, not presented as implemented modes.