Quiz: bilateral filter and non-local means

Short questions to test your understanding. Try each on paper first, then open the answer. Both filters output \hat u_p = \sum_q w_{pq}I_q/\sum_q w_{pq}; bilateral: w = e^{-|p-q|^2/2\sigma_s^2}e^{-(I_p - I_q)^2/2\sigma_r^2}; NLM: w = e^{-d^2/h^2} with d^2 the mean squared patch difference.


Q1. What does the bilateral weight map look like at a pixel in a flat region, next to a straight edge, and at a corner?

Which neighbours have a similar value?

Flat: a round Gaussian blob (all neighbours similar): there it is a Gaussian blur. Edge: a half-moon on the pixel’s own side. Corner: a quarter (the pixel’s own quadrant, for a convex corner).


Q2. Weights (1, 1, 1, 1) and (1, 0.1, 0.1, 0.1): what is N_{\text{eff}}, and by how much does each reduce the noise?

N_{\text{eff}} = (\sum w)^2/\sum w^2; noise falls by \sqrt{N_{\text{eff}}}.

16/4 = 4: noise ÷ 2. 1.3^2/1.03 = 1.64: noise ÷ 1.28. One dominant weight means little averaging, however many small weights there are.


Q3. Why does a bilateral-filtered image keep a thin noisy rim along every edge?

Count the pixels that are averaged next to an edge.

Next to an edge only the pixel’s own side gets weight (half-moon), so fewer pixels are averaged: on the test card N_{\text{eff}} falls from about 44 in flat regions to 25 at an edge and 15 at a corner. Less averaging means more noise left there.


Q4. Non-local means on an image with noise \sigma_n = 10. Two patches of exactly the same structure: what is their expected mean squared difference? Why is h = 3 a bad choice?

Each patch has its own noise.

About 2\sigma_n^2 = 200. With h = 3 their weight is e^{-200/9} \approx 2 \cdot 10^{-10}: even perfect copies get no weight, only the pixel itself (d = 0) counts, and nothing is averaged.


Q5. Which filter would you use for (a) a crystal lattice in electron microscopy, (b) a single vesicle, (c) a noisy fluorescence channel recorded together with a clean bright-field image?

Which filter needs copies, which needs a guide?

  1. NLM: the lattice repeats, so every unit cell finds many copies. (b) Not NLM (no copies: only the pixel itself is averaged); a bilateral filter or TV, which only need the vesicle to be brighter than the noise. (c) Joint bilateral guided by the bright-field image, checking that its edges really are edges in the fluorescence (it copies the guide’s edges).

Q6. What happens if you apply the bilateral filter ten times in a row?

The range weight is an edge-stopping function.

It behaves like Perona–Malik run for a long time: regions become flat (“cartoon”), strong edges stay sharp, weak structures (contrast comparable to σr) are merged away. On the test card the PSNR falls from 33.0 dB (one pass) to 23.3 dB (ten).


Q7. In what sense is non-local means “a diffusion”?

Think of the weights as edges of a graph.

With pixels as nodes and NLM weights as edges, one NLM pass replaces each pixel by the weighted mean of its graph neighbours: one explicit heat step on that graph (with the random-walk Laplacian and Δt = 1). The graph connects look-alike pixels, so heat flows between similar structures, wherever they are.


Q8. (math) Show that the variance of a weighted mean of independent values with variance \sigma^2 is \sigma^2/N_{\text{eff}}.

\mathrm{Var}(\sum a_q X_q) = \sum a_q^2\,\mathrm{Var}(X_q) for independent X_q.

With a_q = w_q/\sum w: \mathrm{Var} = \sigma^2\sum_q w_q^2/(\sum_q w_q)^2 = \sigma^2/N_{\text{eff}}.