M08 · Mathematics alongside
Variations and function spaces
A small image change alters total energy. First observe the tradeoff, then state the assumptions behind the mathematics.
Mathematical support for the textbook chapters: start with a small calculation, then an interactive example and precise definitions.
Work through a small example
A step and a smooth ramp share the same endpoints. Which does total variation prefer?
- Step
- Smooth ramp
- Squared differences behave differently
Here TV prefers neither version, whereas squared differences favor the ramp. This is why TV permits sharp edges. Choosing a reconstruction also needs agreement with observations; variation alone does not determine the answer.
Optimize an entire function, not one number
A functional E[u] maps a function u to one number, for example data fit plus a gradient penalty. Variation u+εv is a small perturbation along an admissible function v. Its derivative in ε at zero indicates whether that direction decreases energy.
For smooth integrand , sufficiently smooth u and fixed boundary values, integration by parts gives the necessary stationarity condition . Free boundaries produce natural boundary conditions. Stationarity does not guarantee a minimum without additional properties, such as suitable convexity.
Keep the observation fixed and change regularization weight: how much detail is traded for a smoother result? This balances data agreement and variation. The example uses smoothed TV; it does not depict contour motion or every BV definition below.
Data fit and image simplicity
Increase smoothness weight and follow actual energy over iterations. Compare edges and small oscillations.
Exact values are in the point inspector
Grayscale 0…1: black to white.
- Data gradient: previous value − observation
- TV gradient: left q + upper q − right q − lower q
- Add both gradients
- Value − accepted step × gradient
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
Total energy combines disagreement with the observation and a penalty on brightness changes. Changing λ changes the objective itself: heights from different settings are not comparable quality scores.
- Total E(u)
- Data disagreement
- Variation penalty × λ
- Displayed iteration: 8
Energy decreases through checked backtracking. This belongs to the chosen convex smoothed model, not a promise of perfect restoration.
- MSE
- 0.0006
- RMSE
- 0.0255
- PSNR (range 0–1)
- 31.8805 dB
Parameters and details
Heat: explicit four-neighbor scheme, dt≤0.24, repeated boundaries. TV: ½||u−f||² + λΣ(√(dx²+dy²+ε²)−ε); backtracking enforces nonincreasing energy. This is smoothed convex TV, not Perona–Malik or exact nonsmooth ROF.
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.
Weak derivatives accommodate limited smoothness
Definitions and details
A weak derivative is defined by integration against compactly supported smooth test functions, not by a pointwise limit everywhere. Space contains functions and their first weak derivatives in ; p=2 is often written . This describes integrability rather than pointwise smoothness of a rendered grid.
BV functions have bounded variation: their distributional derivative can be a finite measure. This accommodates edge jumps. A step has a jump and belongs to BV even though its derivative is not an ordinary function. A discrete image is finite, but its regularizer inherits these different continuous-model preferences.
TV accommodates jumps but has its own artifacts
Definitions and details
For smooth u, . In BV it is the total mass of the derivative measure. ROF minimizes on a suitable space. With convex TV and λ≥0, a strictly convex quadratic gives uniqueness where the problem is well posed; it does not guarantee best visual quality.
The expression is singular at zero gradient. Replacing the denominator with defines a different smoothed energy, not 'the same exact TV'. Nonsmooth methods can use subgradients and dual variables. TV can produce staircasing in smooth ramps and contrast bias.
A curve can also be an unknown
Definitions and details
Segmentation energy can include data inside and outside a contour plus boundary length. An active contour moves under a chosen criterion. A level set represents the contour as a function's zero level and permits topology changes; it is a representation, not proof of correct segmentation.
Mumford–Shah jointly models a piecewise-smooth image and boundaries; Chan–Vese uses a simplified piecewise-constant model. Initialization and local minima can affect the result. Discrete operators, step size and boundaries must match the displayed energy, or an animation does not demonstrate the claimed method.