Topic: removing noise
A noisy image is the true image plus something random. Can we get the true image back? Not exactly. Noise and fine detail overlap, so any method that removes one also removes some of the other. Every denoiser in this course makes a guess, and the guess rests on a belief about what images look like: smooth, piecewise constant, repetitive, sparse in some basis, or “like the training images”. A denoiser works where its belief is true of the image, and does harm where it is not.
The course meets denoising on at least eight days. This page puts the methods side by side: what each assumes, what it costs, what it keeps and when it fails, with links to the units and demos. Read the plain text for the ideas. The one The math box near the end ties the methods together as one formula, and you can skip it.
The shortest path: filtering → camera noise → linear deconvolution (Wiener as a denoiser) → denoising and what you may measure. Then pick by interest: wavelet shrinkage, the edge-preserving smoothing day (it ends with all smoothers on one image), MRF denoising, and learned denoisers.
The question in plain words

tools/figs/topics-denoising/). Gaussian 23.1 dB, median 21.3, Wiener with the true power spectrum 23.8, bilateral 21.8, total variation 23.0, wavelet shrinkage 22.3, non-local means 22.5. Micrograph: R. M. Hunt, CC BY 3.0, Wikimedia Commons.Three things to see in this figure:
- The gains are modest. On a real image full of fine texture, the best method gains about 5 dB, and the methods are within 2.5 dB of each other.
- The ranking depends on the image. Here the best linear filter (Wiener) comes first, because this micrograph is texture everywhere and has few clean edges. On a test card with straight edges and repeating dots, non-local means wins by 4 dB (smoothers: NLM 34.6 dB, TV 30.6, Gaussian 27.4).
- Equal scores do not mean equal results. Gaussian and TV have almost the same PSNR here, but they look completely different (zoom below).
Where the noise comes from, and how big it is
Before choosing a method, know the noise (camera noise):
- Shot noise is part of light itself: a pixel that collects N photons varies by about \sqrt N. Its variance grows with the brightness (Poisson).
- Read noise from the electronics has the same variance everywhere (Gaussian).
- Outliers (hot pixels, cosmic rays) are rare but large; salt-and-pepper noise is the extreme case.
Most methods below assume Gaussian noise of one known level σ. Estimate σ from the image itself: the median of the absolute fine-scale differences is barely affected by edges and spots (shrinkage, spot-threshold). For Poisson noise, either use a method that knows the noise model (Richardson–Lucy, Poisson data terms), or first apply a variance-stabilising transform such as 2\sqrt{x + 3/8}, which makes the noise level about the same everywhere (spot-threshold).
Four families of denoisers
- Average the neighbours. Gaussian, box, the heat equation, Wiener. These are linear, fast and well understood. Noise and structure are averaged alike, so every edge is blurred.
- Choose whom to average with. The median takes the middle value. The bilateral filter averages only neighbours of similar value. Non-local means averages pixels whose whole patch looks similar. Perona–Malik diffusion stops at strong gradients. These keep edges, but each has its own way of losing detail.
- Minimise an energy: fit the data, plus a penalty for implausible images. A quadratic penalty on the gradient gives smooth results. Total variation gives piecewise-constant ones. An \ell^1 penalty on wavelet coefficients or on a sparse code over learned patches gives sparse ones. The Ising prior does the same for binary images. The penalty is the belief, written down.
- Learn the belief from examples. A network trained on noisy/clean pairs learns the average clean image that could explain the noisy one. A generative model can instead draw one plausible clean image, which looks sharp but may contain invented detail.
All denoisers side by side
| Method | Believes the image is… | Cost | Keeps | Fails when | Taught in |
|---|---|---|---|---|---|
| Gaussian / box (= heat flow) | smooth | one separable blur | nothing in particular | edges, lines, small spots (all blurred) | kernels, heat-equation |
| Wiener | an “average” image with a known power spectrum | two FFTs | what lies above the noise per frequency | sharp, sparse structures; the spectrum must be known | deconv, denoise |
| median | made of structures wider than the window; outliers rare | a sort per window | steps; removes outliers | thin lines and dots (removed), corners (rounded) | denoise, morph-grey |
| Perona–Malik | piecewise smooth, edges stronger than K | many explicit steps | strong edges (even sharpens them) | weak edges, ramps (staircases); must be stopped | perona-malik |
| bilateral | nearby, similar values belong together | a window of weights per pixel | edges, lines | noise as large as the edges; ramps become cartoon | denoise, bilateral-nlm |
| non-local means | it repeats itself (similar patches elsewhere) | patch comparisons over a search window: the most expensive classical filter | repeated texture, long edges | unique fine detail (only the pixel itself matches) | denoise, bilateral-nlm |
| quadratic penalty (Tikhonov, Gaussian MRF) | smooth (small gradients everywhere) | one sparse linear system or FFT | smooth regions | edges (blurred, like a low-pass) | gmrf, regularise |
| total variation | piecewise constant, short edges | an iterative solver | steps, plateaus | ramps (staircases), texture, small low-contrast objects (lose contrast) | gmrf, tv-flow |
| wavelet shrinkage | few large wavelet coefficients | a fast transform and a threshold | edges and smooth parts | textures with many medium coefficients; blocky artefacts without cycle spinning | shrinkage |
| sparse coding over a dictionary | patches are sparse combinations of learned atoms | dictionary learning plus a pursuit per patch | structures the atoms have learned | structures the dictionary has not seen | ista, dictionaries |
| Ising prior (binary) | neighbouring labels agree | a graph cut (exact) or ICM | large regions | thin structures (removed when λ is large) | mrf-denoise |
| learned denoiser (posterior mean) | like the training images | training data and a network | what the data determine | far from the training data; rare structures pulled to common ones | score-matching |
| generative restoration (posterior sample) | like the training images, sharp | many network evaluations per image | a plausible, sharp image | detail where the data are weak is invented (or removed) | diffusion, diffusion-inverse |
What each one removes
Every denoiser has a strength knob, and turning it up trades remaining noise for lost signal. The useful question is: for the same noise left over, how much of a small structure survives?
Read the curves as beliefs tested against structures:
- A thin line is the worst case for the median (a minority in every window) and the best case for non-local means (many similar patches along the line).
- Small discs are unique, low-contrast objects. Every method loses them as it smooths more, and TV and non-local means hold them longest.
- No method sits in the top-right corner: no free lunch.
Up close, at their best-PSNR settings, the methods leave different marks:

The smoothers unit runs the same comparison with eight methods and four more scores (SSIM, edge width, line and disc contrast, staircasing). No method wins every score.
Try it
Eight smoothers on one test card, each at its best PSNR. Click a result to change its strength; the tabs show method noise, profiles and scores. Try the presets for salt-and-pepper noise, Poisson noise, strong noise, texture, and “best PSNR against best look”.
The same demo with questions: smoothers exercise.
The average answer and a plausible answer
Learned denoisers make one distinction sharp, and it holds for every method on this page. Should the result be the average of all clean images that could have produced the measurement, or one of them?
- The average (posterior mean) has the best PSNR. Where the data are ambiguous it is a blur between the possibilities, and it may look like no real image. Classical methods and networks trained with squared error give this answer (score-matching).
- A sample looks real and sharp, but where the data are weak its detail comes from the training images, not from the measurement. On average its squared error is twice that of the mean. Two samples disagree exactly where the detail is invented (diffusion, diffusion-inverse).
- Neither is “the truth”. A disagreement map (several samples or several models) shows where the result comes from the prior rather than from the data.
The diffusion demo shows this on synthetic cells: in a heavily blurred cell with two nucleoli, the samples show 1 or 2 nucleoli and the mean shows none, and an unusual ring-shaped nucleus is “corrected” to a normal one.
Denoising and measurement
A denoised image is an estimate: change the method, the strength or the stopping point, and it changes. Use it for what it is good at, and measure on the raw data (denoise, compress-science).
| Use | Denoise first? | Why |
|---|---|---|
| looking, figures | yes, and say how | easier to see; label the method and settings |
| segmentation (thresholds, seeds, edges) | often, with an edge-preserving method | cleaner masks (smoothers: a threshold after TV had 105 wrong pixels, after a Gaussian 151) |
| spot detection | the filter is the matched filter | a separate denoiser before it only changes the noise model of the threshold (spot-filters) |
| total intensity in a region | no: measure on the raw image inside the mask | averaging filters keep the total over large regions, but peaks, sizes and counts change |
| counting small objects, sizes near the resolution | carefully | smoothing merges and removes small objects; restoration can split or invent them |
| anything learned or generative | check | compare with a classical baseline; a disagreement map; never measure invented detail |
Choosing a denoiser
- Outliers or salt-and-pepper? Median.
- Poisson counts, few photons? A variance-stabilising transform, then any method below. Or a method with a Poisson data term.
- Flat regions with sharp edges (labels, cells on a flat background)? TV, bilateral, Perona–Malik.
- Repeated texture, long straight edges? Non-local means, a learned dictionary.
- Smooth images, or measurement to follow? A light Gaussian or Wiener: the least surprising.
- Many images of the same kind and a training set? A learned denoiser, checked against a classical baseline. Report the method.
- Binary images? An Ising/MRF prior solved by a graph cut.
Almost every method on this page is a MAP estimate: the image \mathbf u that best balances fitting the noisy data \mathbf y against a penalty R (the negative log of the prior):
\hat{\mathbf u} = \arg\min_{\mathbf u}\ \frac{1}{2\sigma^2}\|\mathbf u - \mathbf y\|^2 + \lambda\,R(\mathbf u).
| Method | Penalty R(\mathbf u) | Result |
|---|---|---|
| quadratic (Tikhonov, Gaussian MRF) | \sum\|\nabla u\|^2 | a linear low-pass filter, (I + \lambda' L)^{-1}\mathbf y |
| Wiener | \sum_f \|\hat u(f)\|^2/P(f) | gain P/(P + \sigma^2) per frequency |
| total variation | \sum\|\nabla u\| | piecewise constant |
| wavelet shrinkage | \|W\mathbf u\|_1, W orthogonal | soft threshold of each coefficient |
| sparse coding | \|\boldsymbol\alpha\|_1 with \mathbf u = D\boldsymbol\alpha | ISTA / pursuit per patch |
| Ising (binary u) | \sum_{p \sim q}[u_p \ne u_q] | a minimum cut |
| median (per window) | data term \sum\|u - y_q\| instead of squares | robust to outliers |
The neighbourhood filters are weighted averages \hat u_p = \sum_q w_{pq}\,y_q / \sum_q w_{pq} with weights G_s(p - q) (Gaussian), \times\,G_r(y_p - y_q) (bilateral), or G_h(\|\mathbf P_p - \mathbf P_q\|) over patches (non-local means). Each is one step of a diffusion on a graph whose edge weights are the w_{pq} (bilateral-nlm).
Learned denoisers minimise the expected squared error, so they converge to the posterior mean, which Tweedie’s formula ties to the score of the noisy data:
\mathbb E[\mathbf x \mid \mathbf y] = \mathbf y + \sigma^2\,\nabla \log p_\sigma(\mathbf y).
For a Gaussian prior this is exactly the Wiener filter. A posterior sample \tilde{\mathbf x} has, given \mathbf y, expected squared error 2\,\mathrm{tr}\,\mathrm{Cov}(\mathbf x \mid \mathbf y), twice that of the mean (diffusion).
Demos on this topic
| Demo | What it shows |
|---|---|
| Camera noise | shot and read noise, SNR |
| Filtering | averaging kernels |
| Deconvolution lab | Wiener and Tikhonov (with no blur: denoisers) |
| Denoisers and what may be measured | Gaussian, median, bilateral, NLM; method noise; measurements |
| Wavelet shrinkage and in 1D | hard and soft thresholds |
| Heat flow | smoothing as diffusion |
| Edge-stopping diffusion | Perona–Malik |
| TV flow | small things go first |
| Bilateral and NLM weight maps | who is averaged with whom |
| Eight smoothers compared | all classical methods on one card |
| Quadratic, Huber and TV in 1D | priors as penalties |
| Denoising a binary image | Ising prior, ICM against graph cut |
| Restoring with a sparsity prior and with dictionaries | sparse coding |
| Pairs, averages and a learned network | the learned denoiser is a conditional mean |
| Which details are real? | posterior mean against samples, hallucination |
| Measured and imagined, in 1D | what the data determine and what the prior fills in |