Noise & Denoising
COMPUTATIONAL ASPECTS OF DIGITAL PHOTOGRAPHY
Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu
COMPUTATIONAL PHOTOGRAPHY
CS 89.15/189.5, Fall 2015
C OMPUTATIONAL A SPECTS OF C OMPUTATIONAL D IGITAL P HOTOGRAPHY P - - PowerPoint PPT Presentation
CS 89.15/189.5, Fall 2015 C OMPUTATIONAL A SPECTS OF C OMPUTATIONAL D IGITAL P HOTOGRAPHY P HOTOGRAPHY Noise & Denoising Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu Todays agenda Info on paper discussions Noise Denoising with
Noise & Denoising
Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu
CS 89.15/189.5, Fall 2015
Info on paper discussions Noise Denoising with multiple images
Noise characteristics Sources of noise Class portraits!
CS 89/189: Computational Photography, Fall 2015 2
https://youtu.be/o9BqrSAHbTc
30 minutes per paper (presentation + discussion) You may use Powerpoint/Keynote, blackboard, etc. Focus on getting across the main points of the paper first
understand.
approach.
technical parts of the paper (algorithms, equations, etc).
CS 89/189: Computational Photography, Fall 2015 4 After a webpage by Kyros Kutulakos
Everyone will have read the paper before class.
theory) works and deciding how to present this in class.
in which things are described in the paper.
CS 89/189: Computational Photography, Fall 2015 5 After a webpage by Kyros Kutulakos
A paper's content may not be sufficient to fully describe how a technique works.
A major goal of your presentation is to fill in these gaps and present a complete picture of the paper in class. If there is something you don't understand, you must either work it out yourself, or come to office hours so that we can resolve it together.
CS 89/189: Computational Photography, Fall 2015 6 After a webpage by Kyros Kutulakos
Some authors provide presentations and other material
Practice, practice, practice
yourself, before coming to class.
classmates’ presentation style, level of preparation, etc. with an eye toward improving your own presentation skills.
CS 89/189: Computational Photography, Fall 2015 7 After a webpage by Kyros Kutulakos
Everyone else will not be a passive observer Discussant will initiate and facilitate the discussion Everyone is expected to participate in the discussions
CS 89/189: Computational Photography, Fall 2015 8
Limitations
Future work? Relations/comparisons
CS 89/189: Computational Photography, Fall 2015 9
Usually for dark conditions
CS 89/189: Computational Photography, Fall 2015 11 After a slide by Frédo Durand
Fluctuation when taking multiple shots
CS 89/189: Computational Photography, Fall 2015 12 After a slide by Frédo Durand
After a slide by Frédo Durand
What should the histogram be within this box?
After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015
15
Should be single values for RGB (constant color)
After a slide by Frédo Durand
Noise exists Noise can be observed as:
CS 89/189: Computational Photography, Fall 2015 17 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015
mean = imSeq[1] for i = 2 to imSeq.size(): mean += imSeq[i] mean /= imSeq.size()
19 After a slide by Frédo Durand
After a slide by Frédo Durand
After a slide by Frédo Durand
After a slide by Frédo Durand
Denote pixel values like random variables X Mean: μ or E[x], the true measurement Variance: σ2[x] = ~ average squared error
Standard deviation: σ[x] = square root of variance
CS 89/189: Computational Photography, Fall 2015 24
σ2[x] = E[(E[x] − x)2] σ2 = E[x2] − E[x]2
After a slide by Frédo Durand
Say we have N measurements xi How would you estimate their mean?
CS 89/189: Computational Photography, Fall 2015 25
µN = 1 N ∑ xi
Say we have N measurements xi How would you estimate their variance? Use original definition:
CS 89/189: Computational Photography, Fall 2015 26
σ2[x] = E[(E[x] − x)2] σ2
N = 1
N ∑(µN − xi)2 µN = 1 N ∑ xi
Divide by N-1, not by N
and variance, which introduces correlation that underestimates variance
CS 89/189: Computational Photography, Fall 2015 27
σ2
N = 1
N ∑(µN − xi)2 σ2
N =
1 N − 1 ∑(µN − xi)2
After a slide by Frédo Durand
We do 2 coin flips Try to estimate mean & variance Sometimes we’ll be wrong
CS 89/189: Computational Photography, Fall 2015 28 After a slide by Frédo Durand
4 scenarios: (0,0) ; (0, 1) ; (1, 0) ; (1, 1)
true variance: 0.25 sum of squared differences to sample mean: 0; 0.5; 0.5; 0 estimator 0 ; 0.25 ; 0.25 ; 0
estimator 0 ; 0.5 ; 0.5 ; 0
CS 89/189: Computational Photography, Fall 2015 29
σ2
N = 1
N ∑(µN − xi)2 σ2
N =
1 N − 1 ∑(µN − xi)2
After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 30
SNR = mean pixel value standard deviation of pixel value = µ σ log SNR(dB) = 10 log10 ✓µ2 σ2 ◆
= 20 log10
⇣µ σ ⌘
After a slide by Marc Levoy
Be careful. Sometimes variance is zero (for no good reason) and will break things
1e-6
CS 89/189: Computational Photography, Fall 2015 31 After a slide by Frédo Durand
Analyze how the mean & variance evolve when we denoise by averaging multiple frames Formula for average:
CS 89/189: Computational Photography, Fall 2015 33
= 1
N ∑ xi
After a slide by Frédo Durand
E[kx] = E[x+y] = E[xy] =
CS 89/189: Computational Photography, Fall 2015 34 After a slide by Frédo Durand
E[kx] = kE[x] E[x+y] = E[xy] =
CS 89/189: Computational Photography, Fall 2015 35 After a slide by Frédo Durand
E[kx] = kE[x] E[x+y] = E[x]+E[y] E[xy] =
CS 89/189: Computational Photography, Fall 2015 36 After a slide by Frédo Durand
E[kx] = kE[x] E[x+y] = E[x]+E[y] E[xy] = E[x]E[y]?
CS 89/189: Computational Photography, Fall 2015 37 After a slide by Frédo Durand
E[kx] = kE[x] E[x+y] = E[x]+E[y] E[xy] = E[x]E[y]
CS 89/189: Computational Photography, Fall 2015 38
E[xy] = Z
y
Z
x
xy p(x, y)dxdy = Z
y
Z
x
xy p(x)p(y)dxdy = Z
y
p(y)y Z
x
x p(x)dxdy = Z
y
p(y)yE[x]dy = E[y]E[x]
After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 39
σ2[x] = E[(E[x] − x)2] = E[E[x]2 − 2xE[x] + x2] = E[x]2 − 2E[x]E[x] + E[x2] = −E[x]2 + E[x2]
After a slide by Frédo Durand
σ2 = E[x2] − E[x]2
Multiplication by k: Addition of two random variables
CS 89/189: Computational Photography, Fall 2015 40
σ2[kx] = E[(kx)2] − E[kx]2 = k2σ2[x] = E[x2 + 2xy + y2] − (E[x] + E[y])2 = E[x2] + E[y2] + E[2xy] − E[x]2 − E[y]2 − 2E[x]E[y] σ2[x + y] = E[(x + y)2] − E[x + y]2 = E[x2] − E[x]2 + E[y2] − E[y]2 = σ2[x] + σ2[y]
uncorrelated: E[xy]=E[x]E[y] variance is additive! not linear, quadratic! After a slide by Frédo Durand
Noise/measurement as random variable Mean, variance, standard deviation Variance:
SNR, log of SNR
CS 89/189: Computational Photography, Fall 2015 41 After a slide by Frédo Durand
Assume images are IID random measurements Variance for one image: Average: What is the variance of the average?
CS 89/189: Computational Photography, Fall 2015 43
1 N
N
X
i=1
xi σ2[xi]
After a slide by Frédo Durand
Assume images are IID random measurements Variance for one image: Average:
CS 89/189: Computational Photography, Fall 2015 44
1 N
N
X
i=1
xi σ2[xi] σ2 " 1 N
N
X
i=1
xi # = ✓ 1 N ◆2
N
X
i=1
σ2[xi] = ✓ 1 N ◆2 Nσ2[xi] = 1 N σ2[xi]
After a slide by Frédo Durand
Denoising by averaging:
CS 89/189: Computational Photography, Fall 2015 45 After a slide by Frédo Durand
Assignment 3! Try all possible shifts within +/- maxOffset Keep the one with minimum sum of square differences
CS 89/189: Computational Photography, Fall 2015 47 After a slide by Frédo Durand
Can do denoising by aligning and averaging N images
CS 89/189: Computational Photography, Fall 2015 48 After a slide by Frédo Durand
Camera on tripod, many pictures Compute mean, variance, stddev, SNR
CS 89/189: Computational Photography, Fall 2015 50 After a slide by Frédo Durand
Get the right amount of light to sensor/film Two main parameters:
+ sensor sensitivity (ISO)
In what follows, I kept the exposure the same and explored the tradeoff between shutter speed and ISO
CS 89/189: Computational Photography, Fall 2015 51 After a slide by Frédo Durand
After a slide by Frédo Durand
Looks noisy, especially in dark areas
After a slide by Frédo Durand
Denoised with 45 images (estimator of mean)
After a slide by Frédo Durand
Standard deviation (some alignment issues...)
After a slide by Frédo Durand
Standard deviation (some alignment issues...)
For each pixel, for each channel, compute and display as an image σN = r 1 N − 1 ∑(µN − xi)2
After a slide by Frédo Durand
Standard deviation (some alignment issues...)
Observations: more noise in bright image areas more less
After a slide by Frédo Durand
log SNR
After a slide by Frédo Durand
log SNR — looks a lot like the image!
even though we have more noise, bright areas have better SNR
After a slide by Frédo Durand
Noise is more visible in dark areas Noise is numerically higher in bright areas SNR is better in bright areas
CS 89/189: Computational Photography, Fall 2015 60
After a slide by Frédo Durand
After a slide by Frédo Durand
A lot less noisy!
After a slide by Frédo Durand
Standard deviation (some alignment issues...)
After a slide by Frédo Durand
Standard deviation (some alignment issues...)
After a slide by Frédo Durand
log SNR
After a slide by Frédo Durand
log SNR
After a slide by Frédo Durand
log SNR
After a slide by Frédo Durand
After a slide by Frédo Durand
After a slide by Frédo Durand
Noise level depends on
CS 89/189: Computational Photography, Fall 2015 71 After a slide by Frédo Durand
The number of photons arriving during an exposure varies from exposure to exposure and from pixel to pixel, even if the scene is completely uniform On average you might get 100 photons, but sometimes it will be 98, sometimes 103, etc. This phenomenon is governed physics and the value follows the Poisson distribution.
CS 89/189: Computational Photography, Fall 2015 73 After a slide by Marc Levoy
Expresses the probability that a certain number of events will
Applicable to events that occur
If on average λ events occur in an interval
CS 89/189: Computational Photography, Fall 2015 74
p(k; λ) = λke−λ k!
After a slide by Marc Levoy
The mean and variance of the Poisson distribution are The standard deviation is Deviation grows slower than average.
CS 89/189: Computational Photography, Fall 2015 75
µ = λ σ2 = λ p(k; λ) = λke−λ k! σ =
√
λ
After a slide by Marc Levoy
Photons arrive in a Poisson distribution so Shot noise scales as square root of number of photons
CS 89/189: Computational Photography, Fall 2015 76
µ = λ σ =
√
λ SNR = µ σ =
√
λ
After a slide by Marc Levoy
log SNR — dominated by Poisson, ~sqrt(image)
After a slide by Frédo Durand
Electrons dislodged by random thermal activity Increases linearly with exposure time Increases exponentially with temperature Varies across sensor
CS 89/189: Computational Photography, Fall 2015 78
Canon 20D, 612 sec exposure
(http://theory.uchicago.edu/~ejm/pix/20d/tests/noise/) After a slide by Marc Levoy
Electrons leaking into well due to manufacturing defects Increases linearly with exposure time Increases with temperature, but hard to model Changes over time, and every camera has them
CS 89/189: Computational Photography, Fall 2015 79 After a slide by Marc Levoy
Solution #1: chill the sensor Solution #2: dark frame subtraction
CS 89/189: Computational Photography, Fall 2015 80 After a slide by Marc Levoy
Manufacturing variations across pixels, columns, blocks Mainly in CMOS sensors Doesn’t change over time, so read once and subtract
CS 89/189: Computational Photography, Fall 2015 81
Canon 20D, ISO 800, cropped
After a slide by Marc Levoy
Thermal noise in readout circuitry Again, mainly in CMOS sensors Not fixed patterns, so only solution is cooling
CS 89/189: Computational Photography, Fall 2015 82
Canon 1Ds Mark III, cropped
After a slide by Marc Levoy
Photon shot noise
will be less noisy
Dark current noise
Hot pixels, fixed pattern noise
Read noise
CS 89/189: Computational Photography, Fall 2015 83 After a slide by Marc Levoy
Photosites transform photons into charge (electrons)
Gets amplified (depending on ISO setting) Then goes through analog-to-digital converter
Stop here when shooting RAW Then demosaicing, denoising, white balance, a response curve, gamma encoding are applied Quantized and recorded as 8-bit JPEG
CS 89/189: Computational Photography, Fall 2015 84 After a slide by Frédo Durand
This is a conceptual diagram, don’t take it too literally
usually electronic noise, not quantization artifacts
CS 89/189: Computational Photography, Fall 2015 85
sensor analog gain (ISO) ADC photon noise additive noise additive noise quantization
voltages numbers
photons digital image
Noise = (photon noise + readout noise) * amplification + post-amplification noise
After a slide by Frédo Durand
e.g. going from ISO 100 to ISO 400 amplifies by 4 both noise & signal
CS 89/189: Computational Photography, Fall 2015 86
sensor analog gain (ISO) ADC photon noise additive noise additive noise quantization
voltages numbers
photons digital image
After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015
87
After a slide by Frédo Durand
A lot less noisy!
CS 89/189: Computational Photography, Fall 2015
88
After a slide by Frédo Durand
For a given signal level, and a given desired image brightness… Two alternatives
The latter gives less noise because you don’t amplify post-gain noise
CS 89/189: Computational Photography, Fall 2015 89
sensor analog gain (ISO) ADC photon noise additive noise additive noise quantization
voltages numbers
few photons digital image
After a slide by Frédo Durand
ISO is a simple gain
But when the signal is low, it’s better to amplify as early as possible (ISO rather than digitally) Ideally, you make sure the signal is high by use a slower exposure or larger aperture
CS 89/189: Computational Photography, Fall 2015 90 After a slide by Frédo Durand
For the same light level and electronic (per photosite read noise), and same total sensor size, is it better to:
yield a 4 Mpixel image
Analyze photon noise and read noise
CS 89/189: Computational Photography, Fall 2015 91 After a slide by Frédo Durand
For bright pixels (in fact, most pixels), photon noise dominates For dark pixels: electronic (read) noise dominates For long exposures, thermal noise kicks in
CS 89/189: Computational Photography, Fall 2015 92 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 93
Frédo Durand Marc Levoy
CS 89/189: Computational Photography, Fall 2015 94