M03 · Mathematics alongside
Derivatives and vector fields
A selected edge becomes measurable change while sign and direction remain visible.
Mathematical support for the textbook chapters: start with a small calculation, then an interactive example and precise definitions.
Work through a small example
The left and right values are 1 and 5. How can we estimate change at the middle cell?
- The samples are two steps apart
This is change per cell, not brightness. Reversing the row makes it negative. If neighboring measurements are h apart, the divisor is 2h.
A difference measures change, not brightness itself
For samples 0.2, 0.2, 0.8, the forward difference right of the second is 0.6. At grid spacing h, estimate the derivative by (I[x+1]−I[x])/h. Backward differences look left; central differences use both sides. Omitting h gives change per pixel, not per meter.
For sufficiently smooth functions the central formula has O(h²) error and one-sided differences O(h). These smoothness estimates do not apply at a jump. Derivatives amplify high-frequency noise, so any presmoothing scale must be stated.
Select an edge: left and right values differ, giving a large horizontal difference. In a uniform region it is near zero. Change derivative direction and compare the same point. Divergence, Hessians and adjoints below remain reference concepts, not hidden modes of this example.
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.
The gradient points toward fastest increase
Definitions and details
The gradient has two components. Its length gives change strength; its direction points toward increasing intensity. An edge curve is approximately perpendicular to the gradient. A zero gradient has no defined direction: atan2(0,0) does not justify a meaningful arrow.
Sobel and Scharr are discrete component estimates with their own smoothing and scale. Normalization changes a numerical threshold even if an auto-contrasted display looks identical. Corners and textures benefit from comparing both components, not only magnitude.
Divergence, Laplacian and curvature
Definitions and details
Divergence measures local outgoing vector-field flow. The Laplacian compares a value with its surroundings. On a square grid of spacing h, its five-point stencil is .
The Hessian is the matrix of second partial derivatives. Continuous second derivatives ensure equality of mixed partials. Its eigendirections describe local scalar-field curvature, not automatically object shape. An integral sums contributions over a region; on a grid this becomes an area-weighted sum.
Optimization needs compatible derivatives
Definitions and details
Integration by parts relates gradient and divergence through a boundary term. Under periodic or suitable zero-flux conditions, gradient and negative divergence are adjoints. On a grid, choose a compatible operator pair with matching boundaries: arbitrary mismatched stencils can invalidate the energy gradient.
This matters especially in TV, diffusion and inverse problems. Checking on small arrays catches a sign or boundary error before an attractive image hides it.