Exam card
- Noise model: g(x,y) = f(x,y) + η(x,y). The goal is to estimate f from g without losing detail. The noise model decides the filter.
- Gaussian (sensor) η ~ N(μ, σ²) · Poisson (shot) K ~ Poisson(λ), mean = var = λ · salt & pepper (transmission/storage, impulse) · speckle (ultrasound/radar, multiplicative g = f·η).
- Noise causes false edges, broken segmentation, hidden features and lost small structures.
- Spatial (on pixels, linear or non-linear) vs frequency domain. Mean (1/9)[1…1] blurs edges · Gaussian (1/16)[1 2 1; 2 4 2; 1 2 1] · median for salt & pepper, keeps edges, non-linear.
- Which filter: Gaussian noise → Gaussian/mean · salt & pepper → median · Poisson → Gaussian/mean, then Wiener · speckle → Lee/Frost.
- Convolution = cross-correlation with the kernel flipped. They are the same for symmetric kernels. CNN "convolution" (PyTorch) is really cross-correlation. Borders: zero · replicate · reflect · valid · truncated.
Key diagram
Key terms
What this topic covers
- What is image noise?
- The four noise sources
- How noise hurts computer vision
- Noise filtering: spatial vs frequency domain
- Cross-correlation vs convolution
- Boundary handling
Deep summary
Everything here follows the Topic 4 slides; each part shows its slide numbers. Parts marked added are study aids we wrote, not lecture content.
1 · The noise model and the filtering problem Topic 4 · slides 3–5, 20–21
An image is a digital record of a scene, and the recorded values can differ from the ideal ones because of sensor limitations, photon statistics, transmission errors and imaging process noise (slide 3).
Model (slide 4): the observed pixel is the original scene value plus the noise at that position, g(x,y) = f(x,y) + η(x,y). Worked: f = 100 and η = +7 give g = 107. We only ever see 107; the filtering problem is to estimate f from g without removing meaningful image details.
The noise model matters: a filter that works well for one type may do poorly on another (slide 5). Why bother? Noise gives false edges in edge detection, splits one object into different regions in segmentation, hides or distorts features in recognition, and small structures can be lost when medical images are denoised (slides 20–21).
The values 100 and +7 are our example.
2 · Two random models: Gaussian (sensor) and Poisson (shot) Topic 4 · slides 6–13
Sensor noise: the sensor’s electronics and thermal effects add random variations, most visible in low-light photos (slide 6): high-ISO shots, dark regions, scientific imaging. Slide 7 shows it growing from ISO 100 to ISO 25600. It is modelled as additive Gaussian noise, η ~ N(μ, σ²) (slide 8).
Adding Gaussian noise, step by step (slide 9): 1. choose the distribution (mean 0). 2. draw independent random samples, one per pixel. 3. add the noise matrix to the image. Worked on a 2 × 3 patch of 100s with noise +2, −3, 0, +1, −1, +4 → g = 102, 97, 100, 101, 99, 104.
Shot noise: light arrives as discrete photons, so the count fluctuates, worse in low light (slide 10). K ~ Poisson(λ): K = photons detected, λ = expected count, and mean = variance = λ (slide 11). Slide 12: λ = 10 → σ = √10 = 3.16; λ = 100 → σ = 10. σ is bigger at 100, but relative to the signal it is smaller (3.16/10 ≈ 32% vs 10/100 = 10%), so dim images show shot noise more. Seen in low-light photography, fluorescence microscopy, astronomy (slide 13).
The noise values are our example. Slide 9 literally says “mean and standard deviation of zero”; a σ of 0 would add no noise, so read it as mean 0.
3 · Extreme pixels and multiplied noise: salt & pepper, speckle Topic 4 · slides 14–19
Transmission and storage errors (transmission errors, defective sensor pixels, processing or storage faults, deliberate corruption) produce extreme or irregular values (slide 14). They are the primary cause of salt and pepper noise, also called impulse noise (slide 15):
g(x,y) = 0 with probability pb (pepper), L − 1 with probability pw (salt), and f(x,y) otherwise. For an 8-bit image L − 1 = 255. So a few pixels jump to black or white and the rest stay exact (slide 16).
Speckle (slides 17–19): coherent systems such as ultrasound and synthetic aperture radar produce a granular pattern. The noise multiplies: g(x,y) = f(x,y) · η(x,y), so the change depends on the pixel value. Worked with η = 1.2: f = 50 → 60 (+10), f = 200 → 240 (+40). Same η, four times the change on the bright pixel.
The window values and η = 1.2 are our examples.
4 · Spatial filters: mean vs Gaussian on one neighbourhood Topic 4 · slides 22–30
Noise filtering reduces unwanted random variation while keeping edges, textures and fine detail (slide 22). Two families: spatial domain (works directly on pixels using neighbours; linear or non-linear) and frequency domain (transform, change the frequency components, transform back) (slide 23). A spatial filter computes a new value from the local neighbourhood: for 3 × 3, the 9 pixels around the centre (slide 24).
Mean (slides 25–26): g′(x,y) = (1/n²) Σi Σj g(x+i, y+j), so for 3 × 3 the kernel is (1/9) × all ones. Worked on the window above: six 10s and three 90s → (60 + 270)/9 = 36.7. Gaussian (slides 28–29): weights from G(x,y) = (1/2πσ²) e−(x²+y²)/2σ², 3 × 3 ≈ (1/16)[1 2 1; 2 4 2; 1 2 1]. Worked: column weights are 4, 8, 4 → (4×10 + 8×10 + 4×90)/16 = 480/16 = 30.
Both are weighted sums, so both pull the dark centre towards the bright side: that is the edge blurring on slides 26–27. The Gaussian moves it less because the centre counts most (4/16 against 1/9). The mean is also pulled hard by outliers (slide 26), and the Gaussian does not reliably remove isolated extreme pixels (slide 30).
5 · The median filter, and which filter for which noise Topic 4 · slides 31–34
The median filter sorts the values in the neighbourhood and selects the middle one (slide 31). It is particularly effective against salt and pepper noise, preserves edges better than linear smoothing filters, and is non-linear, so it cannot generally be written as a fixed convolution kernel.
Worked on a window hit by one salt (255) and one pepper (0): 1. list the 9 values. 2. sort: 0, 10, 11, 12, 13, 14, 15, 16, 255. 3. take the 5th: 13. Compare the linear filters on the same window: mean 346/9 = 38.4, Gaussian 1153/16 = 72.1. The extremes sit at the ends of the sorted list and never reach the middle, which is why slide 32’s speckled brain scan comes out clean.
Which filter? (slides 33–34) Gaussian noise → start with Gaussian or mean, move to advanced filters if fine detail must be kept. Salt & pepper → median. Poisson → Gaussian or mean, then specialised ones such as Wiener. Speckle → speckle-specific methods such as Lee or Frost.
The window values are our example.
6 · Cross-correlation vs convolution, worked Topic 4 · slides 35–37
Cross-correlation multiplies the neighbourhood by the kernel in its original orientation: (f ∗ h)[m,n] = Σi Σj f[m+i, n+j] h[i,j] (slide 35). Convolution uses the same multiply-and-sum, but the kernel is flipped horizontally and vertically first: Σi Σj f[m−i, n−j] h[i,j] (slide 36).
Worked with i, j ∈ {−1, 0, 1} and the asymmetric kernel h[0,−1] = 1, h[0,1] = −1 (all others 0). Cross-correlation: f[m, n−1]·1 + f[m, n+1]·(−1) = 2 − 9 = −7. Convolution: f[m, n+1]·1 + f[m, n−1]·(−1) = 9 − 2 = +7. Same size, opposite sign, exactly the “sign difference” of slide 37. With a symmetric kernel such as the mean or Gaussian, flipping changes nothing.
Slide 37 also warns that many CV libraries and deep-learning frameworks implement “convolution” that is really cross-correlation: standard CNN layers in PyTorch don’t flip the learned kernel.
The 3 × 3 numbers and kernel are our example. Slide 35 writes cross-correlation with the same ∗ symbol as convolution.
7 · Boundary handling: five answers at one edge pixel Topic 4 · slide 38
An n × n kernel cannot fit inside the image when its centre is near an edge (slide 38). The five strategies: zero padding (pixels outside are 0), replication padding (extend the nearest border pixel outward), reflection padding (reflect the image at its boundary), valid filtering (only output where the whole kernel fits) and truncated kernel (use only the pixels caught inside the image).
Worked on a row starting 5, 7, 9 with a 3-wide mean centred on the first pixel (5): zero → (0 + 5 + 7)/3 = 4, the border darkens. Replicate → (5 + 5 + 7)/3 = 5.67. Reflect → (7 + 5 + 7)/3 = 6.33. Truncated → (5 + 7)/2 = 6. Valid → no value at this pixel, so the output is smaller than the input.
added The 1 × 3 row keeps the arithmetic short; a 3 × 3 kernel works the same way in both directions. “Reflect” here mirrors about the edge pixel; some tools repeat the edge pixel instead.
8 · Exam traps Topic 4 · slides 4, 11–12, 15, 17, 26, 30–31, 36–38 added
- Additive vs multiplicative: Gaussian sensor noise is g = f + η (slide 4); speckle is g = f · η (slide 17). Only speckle’s change depends on the pixel value.
- Poisson: mean = variance = λ, so σ = √λ, not λ (slide 11). λ = 100 gives σ = 10.
- Salt & pepper = impulse noise, caused mainly by transmission/storage errors (slide 15), not by the sensor’s heat.
- Gaussian filter ≠ cure for salt & pepper: it does not reliably remove isolated extremes (slide 30). Use the median (slide 31).
- The median is non-linear: no fixed kernel exists for it (slide 31). Mean and Gaussian are linear.
- Convolution flips the kernel both ways (slide 36). If the kernel is symmetric, convolution and cross-correlation are equal (slide 37).
- Valid filtering shrinks the output; the padding methods keep its size (slide 38).
9 · Quick check Topic 4 · slides 11–12, 26, 31 added
Q1. λ = 64 photons on average. What are the mean, variance and standard deviation of the count?
Q2. A 3 × 3 window holds eight 20s and one 200. Give the 3 × 3 mean and the median.
Q3. Why can’t the median filter be written as a kernel H like the mean’s (1/9)[1…1]?
Exam questions · 16 Practise these 16
Q1What is image noise? Give the additive noise model and state the filtering problem.
Q2Describe the four main sources of image noise with their models and where each is seen.
Q3A pixel receives on average 10 photons per exposure. What are the mean and standard deviation of the count? Why does shot noise show more in dark images?
Q4Compare the mean, Gaussian and median filters. Which would you use for salt-and-pepper noise, and why?
Q5Distinguish convolution from cross-correlation. When do they give the same result?
Q6An n × n kernel does not fit at the image border. List the boundary-handling strategies.
Q7Classify · Which noise model fits each case? (a) a high-ISO night photo (b) an astronomy image with very few photons (c) an image sent over a faulty link, with random black and white dots (d) the granular texture of an ultrasound scan (e) a defective sensor pixel.
Q8Calculate · Two pixels have f = 80 and f = 160. Find g under additive noise with η = 5, and under speckle noise with η = 1.25. What does the result show?
Q9Calculate · One pixel expects λ = 25 photons, another λ = 400. Give the standard deviation of each count and say which will look noisier.
Q10Apply · Apply the 3 × 3 mean filter and the 3 × 3 Gaussian approximation to the window (20, 22, 24 / 21, 23, 25 / 22, 24, 26). What is the new centre value?
Q11Calculate · A 3 × 3 window is (50, 52, 0 / 49, 51, 53 / 48, 255, 50). Give the median-filter output and the mean-filter output for its centre. Which is right for this noise?
Q12Match · Match each noise type to the filter the slides recommend: Gaussian, salt & pepper, Poisson, speckle.
Q13Explain · Explain why the median filter is called non-linear and cannot be written as a fixed convolution kernel. Use a small example.
Q14Calculate · Neighbourhood f = (4, 7, 2 / 3, 5, 6 / 8, 1, 9) and kernel h with h[−1,0] = 1, h[1,0] = −1, all others 0. Compute the centre output by cross-correlation and by convolution.
Q15Describe · Describe the two main types of noise filtering and how each produces its output.
Q16Compare · A 6 × 6 image is filtered with a 3 × 3 kernel. Compare the output size under padding (zero, replication, reflection) and under valid filtering, and say what a truncated kernel does instead.
Quick MCQs · 14 MCQs in Practise
Not the exam format: quick checks that you understood the topic. Choose 1 or all that apply, then Check.