Motivation
A painter or diagram often suppresses small variations while retaining selected boundaries. Ordinary averaging smooths everything nearby, so it can blur the very boundary we want to keep. An edge-aware average changes the weights: a nearby pixel with a very different guide value contributes less than a nearby pixel with a similar guide value. This is an explicit algorithmic choice about which variations to smooth, not a complete model of artistic judgment.
Non-photorealistic imaging deliberately changes appearance. A piecewise constant color field with dark lines may communicate shape while discarding texture and subtle lighting. To understand such a result, we should separate the filtering, quantization and line decisions. A method can introduce a visible line that is absent from the measured scene, or retain a noise spike because it resembles an isolated edge. “Edge-preserving” is therefore a qualified description of a weighting mechanism, rather than a promise that all meaningful edges survive and all noise disappears.
We analyze a finite-grid bilateral-type filter and then build a small reproducible stylization pipeline. The proofs distinguish a fixed guide from an adaptively recomputed guide. We will also see why repeated fixed-guide filtering eventually removes every nonconstant component on a connected grid, even if cross-edge weights are very small. Slow smoothing across an edge is not the same as a permanent mathematical barrier.
Definitions
Definition 1.24.1
(Fixed-guide bilateral-type filter)
Let pixels be indexed by a finite set, with scalar image values and positions . Choose symmetric nonnegative spatial weights , with . Zero weights can restrict the neighborhood. A fixed guide and range scale define
The guide can be the input image, a color vector or a different registered measurement. Self-weights ensure . For fixed , this is a linear map of . When is recomputed from the current image, the overall map is nonlinear because the coefficients change with the data. The range distance depends on the chosen guide representation and units.
Definition 1.24.2
(Spatial kernel and the two scales)
A common spatial choice is inside a symmetric neighborhood, with . Here measures spatial scale and measures guide-value scale. Increasing one does not have the same effect as increasing the other. Boundary neighborhoods can have different total weights even when the interior kernel is translation invariant.
Definition 1.24.3
(Quantized base and edge marks)
For an explicit stylization, first compute a smoothed scalar base . Quantize it to levels by a nearest-level map with a specified tie rule. On a one-dimensional row, define edge strength between adjacent pixels, and mark a line when for a chosen threshold . In two dimensions, stated horizontal/vertical differences or another specified gradient operator provide corresponding edge measurements. The threshold and line placement are design parameters, not recovered physical contours.
Theorem/proposition
Theorem 1.24.4
(Positive normalized weights preserve constants and satisfy a range bound)
Under the stated nonnegative spatial weights and positive self-weights, every filtered value is a convex combination of its contributing input values:
Constants are preserved exactly. For fixed guide, . The last bound compares the same linear operator on two signals, not two adaptively recomputed guides.
Theorem 1.24.5
(Fixed-guide iteration preserves a weighted mean and tends to a constant)
Let be symmetric, and let the graph of positive off-diagonal weights be connected. With and positive self-weights as above, repeated application of this same converges to the constant image
At every step the -weighted sum is preserved. The ordinary unweighted sum need not be preserved. The conclusion is about a fixed guide and fixed weights; it is not a theorem about arbitrary nonlinear reweighting.
Disconnected positive-weight components converge separately to their own weighted constants. Exact zero cross-edge weights can therefore maintain a permanent separation. A Gaussian range factor is positive for finite guide differences, so it does not create such zeros by itself. A deliberately truncated spatial neighborhood may still leave the graph connected through many small steps.
Proof sketch or proof idea
Proof
(Convex combinations and the maximum-norm bound)
Define . These numbers are nonnegative and sum to one in each row. Their weighted average lies between the smallest and largest input entries, and averaging a constant returns the same constant. For fixed guide, each difference is , whose absolute value is bounded by the maximum absolute input difference. If the guide changes, the two outputs use different coefficient rows and this short proof no longer applies.
Proof
(Weighted mean and convergence to a constant)
For mean preservation, symmetry gives
To understand convergence, write and . It is similar to the real symmetric matrix , so it has real eigenvalues and a complete eigenbasis after this change of coordinates. The maximum-norm bound implies every eigenvalue lies in . A fixed vector with eigenvalue one must be constant: at a maximal component, a positive average can equal that maximum only when all connected neighbors share it, and connectivity propagates equality.
Eigenvalue minus one is impossible. At a component of largest absolute value, an average equaling the negative of that component would require every positive-weight contributor to have the opposite extremal value. The positive self-weight contradicts that requirement. Therefore all nonconstant modes have eigenvalues of magnitude strictly below one and vanish under repeated application. The preserved weighted sum determines the remaining constant as .
Proof X-ray
Small edge weights slow diffusion; zero weights block it
The convergence proof uses connectivity, not a lower bound saying every edge weight is large. A very small positive bridge still couples two regions, though a corresponding eigenvalue can lie very near one and make mixing extremely slow. Recomputing the guide changes the operator at every iteration, so the fixed spectral decomposition no longer describes the whole run. A visual impression after a few iterations and an infinite-iteration theorem are different claims.
The fixed-guide filter is also the exact minimizer, separately at each output location, of over . Differentiating gives . This local least-squares interpretation does not mean that one pass solves a global edge-aware restoration energy involving differences between all unknown output pixels. The unknowns in that different problem would be coupled.
Concept lensStructural
The filter as one step of a random walk
The weights define a weighted graph on the pixels, and are the transition probabilities of a walk that moves from pixel to pixel . Then is the expected value of after one step from . Symmetry of gives , so the walk is reversible with stationary weights proportional to . The limit is the average of under that stationary distribution.
Worked examples
Worked example 1.24.6
(A two-pixel edge is attenuated, not exactly frozen)
Take two pixels with values and guides zero and one, and all spatial weights equal one. Choose so the cross-range weight is . Then
The original jump one becomes . Its contrast mode has eigenvalue , so after applications of the same operator the jump is , tending to zero. Making smaller slows this process but does not preserve the edge forever. If the isolated bright pixel were noise, the same mechanism could also protect that noise during a short run.
Worked example 1.24.7
(Why the unweighted image average can move)
Use a three-pixel chain with constant guide and
For , one pass gives . Its ordinary sum is , whereas the input sum is one. However the weighted sum is , matching the input weighted sum. Repeated passes converge to at all three pixels. Boundary pixels and the middle pixel have different total neighborhood weights, which explains the difference between ordinary and invariant means.
Worked example 1.24.8
(A complete small stylization decision)
Take input and retain it as a fixed scalar guide. Use self-weight one, immediate-neighbor spatial weights one, and range weights across a unit jump. One pass gives . Quantizing to gives with no ties. Edge strengths measured on the smoothed base are . With threshold , only the middle boundary is marked. This fully specifies a two-tone-with-line design for the row. Measuring gradients after quantization instead would give strengths zero, one, zero: a related but different algorithm.
For color stylization, smoothing all channels with one common set of nonnegative scalar weights keeps every result in the convex hull of contributing color vectors. Filtering each channel with a different guide can combine channel values from different source mixtures and loses that particular convex-hull guarantee. This does not prove that the common-weight result has a preferred perceptual appearance; it establishes a concrete geometric property of the output colors.
Concept lensAnalytic
Smoothing and drawing a line measure different things
The range kernel decides which observed neighbors contribute to a base value. A gradient threshold then decides which changes in that base become explicit lines. Quantization creates further discontinuities by mapping continuous values to discrete levels. These operations need not commute. Their order should be part of the algorithm description, because it changes both small details and the origin of visible boundaries.
A finite implementation can now be audited step by step: specify intensity units and guide; build symmetric neighborhood weights; normalize using only valid contributors; compute one pass or a stated number of passes; quantize with explicit levels; measure gradients at a stated stage; and place lines by a stated rule. Direct filtering costs order the number of neighbor pairs per pass. More iterations and larger spatial neighborhoods cost more, while a narrow range scale can preserve both important edges and unwanted outliers.
Common mistakes
Counterexample mode
Nearest-level quantization can create a large apparent edge
Quantize to levels zero and one, with threshold . Input values and differ by only , but become zero and one. Their output jump is one. Thus a stylized edge may be created by the palette decision rather than inherited as a strong measured edge. A finite palette does not make the map nonexpansive, and its discontinuity must be considered when claiming stability.
Common mistake
(Using the fixed-guide bound with adaptive guides)
The bound compares one operator applied to two signals. The outputs and use different weight rows, so the short proof does not apply. A filter whose guide is the current image is nonlinear, and its stability has to be examined separately.
Common mistake
(Expecting the ordinary average to be conserved)
Normalized weights conserve the -weighted sum, not the ordinary sum. In the three-pixel chain with , one pass changes the ordinary mean from to , while the weighted mean stays . Boundary pixels have smaller total weight than interior ones, so a bilateral-type filter generally changes ordinary average brightness near the image boundary.
Do not call every large gradient an object contour: texture, illumination, shadows, sampling artifacts and noise can also create gradients. Semantic interpretation requires information beyond the finite difference itself.
Common mistake
(The range scale has units)
The range scale also has units. If guide values are multiplied by a positive factor while stays fixed, the range weights change. Scaling both the guide and by the same factor preserves those weights. An implementation using values in cannot blindly reuse a range parameter tuned for . Similarly, a smoothing algorithm's useful settings need not be useful for a deliberate posterization effect.
Summary
An edge-aware weighted mean combines spatial proximity with guide similarity. Positive normalization preserves constants and bounds outputs, while a fixed guide permits linear stability and weighted-mean analysis. Repeated connected fixed-guide filtering ultimately flattens the image; small positive weights delay rather than forbid mixing. Quantization and line extraction create further modeling decisions, so a non-photorealistic pipeline should state their order, thresholds and intended information loss.
Exercises
Quick check
(For the two-pixel fixed operator with cross-weight , compute one-pass output on and the jump after three passes. Find its limiting constant.)
Solution · Answer
The output is , so the jump is . The nonconstant eigenvalue is , giving jump after three passes. The two row sums are equal, so the invariant weighted mean is the ordinary mean , the limiting value at both pixels.
Quick check
(Verify the weighted mean and ordinary mean after one pass for the three-pixel-chain example. Why does a constant input remain fixed even though a nonconstant input's ordinary mean can change?)
Solution · Answer
The output has weighted sum two and weighted mean , matching the input. Its ordinary mean is , while the input ordinary mean is . Constants remain fixed because every row is normalized to sum one. Preservation of the unweighted total would instead require every column also to sum one, which does not hold for this chain operator.
Quick check
(In the four-pixel stylization example, replace the cross-range weight by . Compute the smoothed base and identify boundaries marked by threshold before quantization.)
Solution · Answer
The endpoints remain zero and one. The two inner values are and . Edge strengths are , so only the middle boundary exceeds . Quantization is a subsequent separate step and was not used to obtain these gradient values.
Quick check
(Prove that multiplying both guide values and by the same positive constant leaves weights unchanged. Then explain why quantizing a slightly perturbed input does not satisfy the filter's fixed-guide maximum-norm contraction bound.)
Solution · Answer
The squared guide difference and the squared range scale both gain the same factor, so their quotient and exponential are unchanged. Quantization, however, is a discontinuous nearest-level map: and can map to zero and one. The theorem concerns one fixed positive averaging operator, not a composition with an unrelated discontinuous map. Stability guarantees must be checked for each actual pipeline stage.