C OMPUTATIONAL A SPECTS OF C OMPUTATIONAL D IGITAL P HOTOGRAPHY P - - PowerPoint PPT Presentation

c omputational a spects of
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Noise & Denoising

COMPUTATIONAL ASPECTS OF DIGITAL PHOTOGRAPHY

Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu

COMPUTATIONAL PHOTOGRAPHY

CS 89.15/189.5, Fall 2015

slide-2
SLIDE 2

Today’s agenda

Info on paper discussions Noise Denoising with multiple images

  • Probability review

Noise characteristics Sources of noise Class portraits!

CS 89/189: Computational Photography, Fall 2015 2

slide-3
SLIDE 3

https://youtu.be/o9BqrSAHbTc

slide-4
SLIDE 4

Presentation guidelines

30 minutes per paper (presentation + discussion) You may use Powerpoint/Keynote, blackboard, etc. Focus on getting across the main points of the paper first

  • Present the paper as if everyone skimmed it but forgot it, or didn't

understand.

  • First present the problem that the paper solves and the general

approach.

  • You should then give a clear and concise description of the main

technical parts of the paper (algorithms, equations, etc).

CS 89/189: Computational Photography, Fall 2015 4 After a webpage by Kyros Kutulakos

slide-5
SLIDE 5

Presentation guidelines

Everyone will have read the paper before class.

  • Your job should not be simply reciting what is in the paper
  • Go beyond that, working out exactly how the algorithm (or

theory) works and deciding how to present this in class.

  • The best way to present an approach may not be the order

in which things are described in the paper.

CS 89/189: Computational Photography, Fall 2015 5 After a webpage by Kyros Kutulakos

slide-6
SLIDE 6

Leave no stone unturned

A paper's content may not be sufficient to fully describe how a technique works.

  • may depend on prior papers/techniques

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

slide-7
SLIDE 7

Presentation guidelines

Some authors provide presentations and other material

  • nline.
  • Proper attribution rules apply

Practice, practice, practice

  • You should practice your presentation at home, and time

yourself, before coming to class.

  • Pay attention to what you did (and did not) like about your

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

slide-8
SLIDE 8

Paper discussion

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

slide-9
SLIDE 9

Things to think about

Limitations

  • Do you think everything will work as described?
  • What are the corner/failure cases?
  • The paper may not be forthcoming about limitations

Future work? Relations/comparisons

  • How does the paper relate to other papers we have read?
  • Can you imagine applying the ideas to a different problem?

CS 89/189: Computational Photography, Fall 2015 9

slide-10
SLIDE 10

Noise

slide-11
SLIDE 11

Noisy image

Usually for dark conditions

CS 89/189: Computational Photography, Fall 2015 11 After a slide by Frédo Durand

slide-12
SLIDE 12

Noise

Fluctuation when taking multiple shots

CS 89/189: Computational Photography, Fall 2015 12 After a slide by Frédo Durand

slide-13
SLIDE 13

Canon 1D mark IIN at ISO 3200

After a slide by Frédo Durand

slide-14
SLIDE 14

What should the histogram be within this box?

Canon 1D mark IIN at ISO 3200

After a slide by Frédo Durand

slide-15
SLIDE 15

CS 89/189: Computational Photography, Fall 2015

Photoshop demo

15

slide-16
SLIDE 16

Should be single values for RGB (constant color)

Histogram of grey patch

After a slide by Frédo Durand

slide-17
SLIDE 17

Recap

Noise exists Noise can be observed as:

  • fluctuation over time
  • fluctuation over space when should be constant

CS 89/189: Computational Photography, Fall 2015 17 After a slide by Frédo Durand

slide-18
SLIDE 18

Denoising by averaging

slide-19
SLIDE 19

CS 89/189: Computational Photography, Fall 2015

Averaging pseudo-code

mean = imSeq[1] for i = 2 to imSeq.size(): mean += imSeq[i] mean /= imSeq.size()

19 After a slide by Frédo Durand

slide-20
SLIDE 20

1 image

After a slide by Frédo Durand

slide-21
SLIDE 21

3 images

After a slide by Frédo Durand

slide-22
SLIDE 22

5 images

After a slide by Frédo Durand

slide-23
SLIDE 23

Probabilistic perspective

slide-24
SLIDE 24

Noise statistics / probability

Denote pixel values like random variables X Mean: μ or E[x], the true measurement Variance: σ2[x] = ~ average squared error

  • more precisely: average squared difference to mean

Standard deviation: σ[x] = square root of variance

  • In same unit as measurement

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

slide-25
SLIDE 25

Estimating the sample mean

Say we have N measurements xi How would you estimate their mean?

CS 89/189: Computational Photography, Fall 2015 25

µN = 1 N ∑ xi

slide-26
SLIDE 26

Estimating the sample variance

Say we have N measurements xi How would you estimate their variance? Use original definition:

  • this underestimates variance!

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

slide-27
SLIDE 27

Estimating the sample variance

Divide by N-1, not by N

  • Otherwise, variance would be underestimated on average
  • called Bessel correction: removes bias
  • Intuition: we use the same samples for estimating the mean

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

slide-28
SLIDE 28

Example with coin flip, N=2

We do 2 coin flips Try to estimate mean & variance Sometimes we’ll be wrong

  • e.g. if we get 0 twice, we’ll think variance is zero
  • but we’d like to be right on average (called unbiased)

CS 89/189: Computational Photography, Fall 2015 28 After a slide by Frédo Durand

slide-29
SLIDE 29

Example with coin flip, N=2

4 scenarios: (0,0) ; (0, 1) ; (1, 0) ; (1, 1)

  • mean estimates: 0 ; 0.5 ; 0.5 ; 1
  • average of the mean estimations: 0.5, equal to true mean (unbiased)

true variance: 0.25 sum of squared differences to sample mean: 0; 0.5; 0.5; 0 estimator 0 ; 0.25 ; 0.25 ; 0

  • 0.125 on average, biased

estimator 0 ; 0.5 ; 0.5 ; 0

  • 0.25 on average, unbiased

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

slide-30
SLIDE 30

Signal-to-noise ratio (SNR)

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

slide-31
SLIDE 31

SNR in practice

Be careful. Sometimes variance is zero (for no good reason) and will break things

  • practical hack: take the max of σ2 and a small number, e.g.

1e-6

CS 89/189: Computational Photography, Fall 2015 31 After a slide by Frédo Durand

slide-32
SLIDE 32

Basic probability tools

slide-33
SLIDE 33

Goal

Analyze how the mean & variance evolve when we denoise by averaging multiple frames Formula for average:

  • addition
  • multiply by scalar

CS 89/189: Computational Photography, Fall 2015 33

= 1

N ∑ xi

After a slide by Frédo Durand

slide-34
SLIDE 34

Expected value

E[kx] = E[x+y] = E[xy] =

CS 89/189: Computational Photography, Fall 2015 34 After a slide by Frédo Durand

slide-35
SLIDE 35

Expected value

E[kx] = kE[x] E[x+y] = E[xy] =

CS 89/189: Computational Photography, Fall 2015 35 After a slide by Frédo Durand

slide-36
SLIDE 36

Expected value

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

slide-37
SLIDE 37

Expected value

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

slide-38
SLIDE 38

Expected value

E[kx] = kE[x] E[x+y] = E[x]+E[y] E[xy] = E[x]E[y]

  • only when they are uncorrelated!

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

slide-39
SLIDE 39

Variance identity

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

slide-40
SLIDE 40

Multiplication by k: Addition of two random variables

Variance properties

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

slide-41
SLIDE 41

Take home message

Noise/measurement as random variable Mean, variance, standard deviation Variance:

  • multiplication by k => k2
  • addition => addition

SNR, log of SNR

CS 89/189: Computational Photography, Fall 2015 41 After a slide by Frédo Durand

slide-42
SLIDE 42

Convergence

slide-43
SLIDE 43

Convergence

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

slide-44
SLIDE 44

Convergence

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

slide-45
SLIDE 45

IMPORTANT RESULT

Denoising by averaging:

  • variance is reduced as 1/N
  • standard deviation (error) is reduced by sqrt(N)

CS 89/189: Computational Photography, Fall 2015 45 After a slide by Frédo Durand

slide-46
SLIDE 46

Alignment

slide-47
SLIDE 47

Brute force

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

slide-48
SLIDE 48

Casio EXF1, Google glass

Can do denoising by aligning and averaging N images

CS 89/189: Computational Photography, Fall 2015 48 After a slide by Frédo Durand

slide-49
SLIDE 49

Noise characteristics

slide-50
SLIDE 50

Analyzing noise

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

slide-51
SLIDE 51

Exposure

Get the right amount of light to sensor/film Two main parameters:

  • Shutter speed
  • Aperture (area of lens)

+ 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

slide-52
SLIDE 52

Canon 1D IIN at ISO 3200

After a slide by Frédo Durand

slide-53
SLIDE 53

Canon 1D IIN at ISO 3200

Looks noisy, especially in dark areas

After a slide by Frédo Durand

slide-54
SLIDE 54

Canon 1D IIN at ISO 3200

Denoised with 45 images (estimator of mean)

After a slide by Frédo Durand

slide-55
SLIDE 55

Canon 1D IIN at ISO 3200

Standard deviation (some alignment issues...)

After a slide by Frédo Durand

slide-56
SLIDE 56

Canon 1D IIN at ISO 3200

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

slide-57
SLIDE 57

Canon 1D IIN at ISO 3200

Standard deviation (some alignment issues...)

Observations:
 more noise in bright image areas more less

After a slide by Frédo Durand

slide-58
SLIDE 58

Canon 1D IIN at ISO 3200

log SNR

After a slide by Frédo Durand

slide-59
SLIDE 59

Canon 1D IIN at ISO 3200

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

slide-60
SLIDE 60

Observations

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

slide-61
SLIDE 61

Canon 1D IIN at ISO 3200

After a slide by Frédo Durand

slide-62
SLIDE 62

Canon 1D II, ISO 100

After a slide by Frédo Durand

A lot less noisy!

slide-63
SLIDE 63

Canon 1D IIN at ISO 3200

After a slide by Frédo Durand

Standard deviation (some alignment issues...)

slide-64
SLIDE 64

Canon 1D II at ISO 100

After a slide by Frédo Durand

Standard deviation (some alignment issues...)

slide-65
SLIDE 65

Canon 1D IIN at ISO 3200

After a slide by Frédo Durand

log SNR

slide-66
SLIDE 66

Canon 1D IIN at ISO 1600

After a slide by Frédo Durand

log SNR

slide-67
SLIDE 67

Canon 1D IIN at ISO 400

After a slide by Frédo Durand

log SNR

slide-68
SLIDE 68

Nikon D3s at 1600 ISO

After a slide by Frédo Durand

slide-69
SLIDE 69

Nikon D3s at 1600 ISO

After a slide by Frédo Durand

slide-70
SLIDE 70

Canon 1D Mark IIN at 1600 ISO

After a slide by Frédo Durand

slide-71
SLIDE 71

Recap and questions?

Noise level depends on

  • pixel intensity
  • ISO
  • color channel
  • camera

CS 89/189: Computational Photography, Fall 2015 71 After a slide by Frédo Durand

slide-72
SLIDE 72

Sources of noise

slide-73
SLIDE 73

Photon shot noise

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

slide-74
SLIDE 74

Poisson distribution

Expresses the probability that a certain number of events will

  • ccur during an interval of time

Applicable to events that occur

  • with a known average rate, and
  • independently of the time since the last event

If on average λ events occur in an interval


  • f time, the probability p that k events

  • ccur instead is

CS 89/189: Computational Photography, Fall 2015 74

p(k; λ) = λke−λ k!

After a slide by Marc Levoy

slide-75
SLIDE 75

Poisson distribution

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

slide-76
SLIDE 76

Photon shot noise

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

slide-77
SLIDE 77

log SNR — dominated by Poisson, ~sqrt(image)

Canon 1D IIN at ISO 3200

After a slide by Frédo Durand

slide-78
SLIDE 78

Dark current

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

slide-79
SLIDE 79

Hot pixels

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

slide-80
SLIDE 80

Fixing dark current and hot pixels

Solution #1: chill the sensor Solution #2: dark frame subtraction

  • available on high-end SLRs
  • compensates for average dark current
  • also compensates for hot pixels and FPN

CS 89/189: Computational Photography, Fall 2015 80 After a slide by Marc Levoy

slide-81
SLIDE 81

Fixed pattern noise (FPN)

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

slide-82
SLIDE 82

Read noise

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

slide-83
SLIDE 83

Recap

Photon shot noise

  • unavoidable randomness in number of photons arriving
  • grows as the sqrt of # photons, so brighter lighting and longer exposures

will be less noisy

Dark current noise

  • grows with exposure time and sensor temperature
  • minimal for most exposure times used in photography
  • correct by subtraction, but only corrects for average dark current

Hot pixels, fixed pattern noise

  • caused by manufacturing defects, correct by subtraction

Read noise

  • electronic noise when reading pixels, unavoidable

CS 89/189: Computational Photography, Fall 2015 83 After a slide by Marc Levoy

slide-84
SLIDE 84

Digital pipeline

Photosites transform photons into charge (electrons)

  • The sensor itself is linear

Gets amplified (depending on ISO setting) Then goes through analog-to-digital converter

  • up to 14 bits/channel these days

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

slide-85
SLIDE 85

Pipeline & noise

This is a conceptual diagram, don’t take it too literally

  • e.g. the A-to-D converter is a serious source of noise, but

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

slide-86
SLIDE 86

ISO amplifies

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

slide-87
SLIDE 87

ISO 3200

CS 89/189: Computational Photography, Fall 2015

87

After a slide by Frédo Durand

slide-88
SLIDE 88

ISO 100

A lot less noisy!

CS 89/189: Computational Photography, Fall 2015

88

After a slide by Frédo Durand

slide-89
SLIDE 89

Pipeline & noise

For a given signal level, and a given desired image brightness… Two alternatives

  • use low ISO and brighten digitally
  • use high ISO to get brightness directly

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

slide-90
SLIDE 90

ISO recap

ISO is a simple gain

  • amplifies noise as well

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

slide-91
SLIDE 91

Brain teaser

For the same light level and electronic (per photosite read noise), and same total sensor size, is it better to:

  • have a 16 Mpixel sensor and average groups of 4 pixels to

yield a 4 Mpixel image

  • have a 4Mpixel sensor (with bigger photosites)

Analyze photon noise and read noise

  • careful about adding vs. averaging

CS 89/189: Computational Photography, Fall 2015 91 After a slide by Frédo Durand

slide-92
SLIDE 92

Different regimes

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

slide-93
SLIDE 93

Questions?

CS 89/189: Computational Photography, Fall 2015 93

slide-94
SLIDE 94

Slide credits

Frédo Durand Marc Levoy

CS 89/189: Computational Photography, Fall 2015 94