Lec4 Exposure HDR Imaging
Lec4 Exposure HDR Imaging
BBM444
FUNDAMENTALS OF
COMPUTATIONAL
PHOTOGRAPHY
Lecture #04 – Exposure and High-Dynamic-Range Imaging
Erkut Erdem // Hacettepe University // Spring 2022
Today’s Lecture
• Controlling exposure
• High-dynamic-range imaging
• Tonemapping
Disclaimer: The material and slides for this lecture were borrowed from
—Ioannis Gkioulekas’ 15-463/15-663/15-862 “Computational Photography” class
—Wojciech Jarosz’s CS 89.15/189.5 “Computational Aspects of Digital Photography” class
—Derek Hoiem’s CS 498 “Computational Photography” class
2
Light, exposure and dynamic range
• Exposure: how bright is the scene overall?
• Dynamic range: contrast in the scene
• ratio of brightest to darkest intensity
3
Today’s Lecture
• Controlling exposure
• High-dynamic-range imaging
• Tonemapping
4
Exposure control
5
What is exposure?
Roughly speaking, the “brightness” of a captured image given a fixed scene.
6
Exposure controls brightness of image
Aperture
Exposure
Shutter ISO
7
Exposure controls brightness of image
Aperture
Exposure
Shutter ISO
8
Shutter speed
Controls the length of time that shutter remains open.
incoming
light
shutter
sensor
closed shutter
9
Shutter speed
Controls the length of time that shutter remains open.
incoming
light
shutter
sensor
open shutter
10
Shutter speed
11
Shutter speed
Controls the period of time that shutter remains open.
incoming
light
shutter
sensor
open shutter
What happens to the image as we increase shutter speed?
12
Side-effects of shutter speed
Moving scene elements appear blurry.
Shah et al. High-quality Motion Deblurring from a Single Image, SIGGRAPH 2008 14
Exposure controls brightness of image
Aperture
Exposure
Shutter ISO
15
Aperture size
Controls area of lens that lets light pass through.
Also determines
circle of confusion.
Also determines
circle of confusion.
You can see the aperture by removing the lens and looking inside it.
18
Side-effects of aperture size
Depth of field decreases as aperture size increases.
• Having a very sharp depth of field is known as “bokeh”.
19
How can we simulate bokeh?
20
How can we simulate bokeh?
Infer per-pixel depth, then blur with depth-dependent kernel.
• Example: Google camera “lens blur” feature
Barron et al., “Fast Bilateral-Space Stereo for Synthetic Defocus,” CVPR 2015 21
Back plane focus, close-up Back planeTraining with triplets
focus, close-up Training w
How
(3C)can
Effectwe simulate
of photo triplets (3C) bokeh?
in training. Wephoto
Effect of compare the in
triplets disparity
training.map
We co
ames and shallow DOF rendering and using networks
shallow DOFtrained w and
rendering usingw networks
triplet tra
Employ a learning-based strategy, i.e. an image-to-image translation model
consistency. The results withconsistency.
triplet consistency are geometrically
The results more
with triplet consistency
accurate in the background region of high
accurate disparity.
in the background region of high dispar
close-up
Zhang et al., “Synthetic Defocus and Look-Ahead Autofocus for Casual Videography,” SIGGRAPH 2019 22
Exposure controls brightness of image
Aperture
Exposure
Shutter ISO
23
The (in-camera) image processing pipeline
The sequence of image processing operations applied by the camera’s image signal
processor (ISP) to convert a RAW image into a “conventional” image.
analog front-
end
RAW image
(mosaiced,
linear, 12-bit)
CFA white
denoising
demosaicing balance
final RGB
color tone
compression image (non-
transforms reproduction
linear, 8-bit)
24
Analog front-end
26
Note about the name ISO
27
Camera modes
Aperture priority (“A”): you set aperture, camera sets everything else.
• Pros: Direct depth of field control.
• Cons: Can require impossible shutter speed (e.g. with f/1.4 for a bright scene).
Shutter speed priority (“S”): you set shutter speed, camera sets everything else.
• Pros: Direct motion blur control.
• Cons: Can require impossible aperture (e.g. when requesting a 1/1000 speed for a dark
scene)
Shutter speed priority (“S”): you set shutter speed, camera sets everything else.
• Pros: Direct motion blur control.
• Cons: Can require impossible aperture (e.g. when requesting a 1/1000 speed for a dark
scene)
30
Light metering in modern cameras
• Exposure is set so that this average is exposed at the middle of the sensor’s dynamic
range.
1. Center-weighed.
2. Spot.
3. Scene-specific preset
(portrait, landscape, horizon).
33
Metering challenges: low resolution
Low-resolution can make it difficult to correctly meter the scene and set exposure.
• In which of these scenes is it OK to let the brightest pixels be overexposed?
34
Today’s Lecture
• Controlling exposure
• High-dynamic-range imaging
• Tonemapping
35
Light, exposure and dynamic range
• Exposure: how bright is the scene overall?
• Dynamic range: contrast in the scene
• ratio of brightest to darkest intensity
36
Our devices do not match the world
37
The world has a high dynamic range
1500
25,000 2,000,000,000
400,000
Relative brightness of different scenes, ranging from 1 inside
a dark room lit by a monitor to 2,000,000 looking at the Sun. 38
The world has a high dynamic range
10-6 106
common real-world scenes
39
(Digital) sensors also have a low dynamic range
10-6 106
sensor
10-6 106
common real-world scenes
40
(Digital) images have an even lower dynamic range
high exposure
10-6 106
image
10-6 106
common real-world scenes
41
(Digital) images have an even lower dynamic range
low exposure
10-6 106
image
10-6 106
common real-world scenes
42
Outside is too bright
The dynamic range challenge
Sun overexposed Inside is istoo dark
Examples
Sun overexposed
Inside
Outside is is
Outside too
too dark
toobright
bright
Foreground too dark
Foreground too dark
Sun overexposed
Foreground too dark
After a slide by Frédo Durand
43
Low Dynamic
Low Dynamic Range
Range (LDR)
(LDR)
Longer exposure Shorter exposure
✓ detail
detail ininshadows
shadows ✓ detail
detail ininhighlights
highlights
✗ clipped highlights
clipped highlights ✗ noisy/clipped shadows
noisy/clipped shadows
5 44
(Digital) images have an even lower dynamic range
high exposure
10-6 106
image
10-6 106
common real-world scenes
45
(Digital) images have an even lower dynamic range
low exposure
10-6 106
image
10-6 106
common real-world scenes
46
(Digital) images have an even lower dynamic range
Any guesses about the dynamic range of a standard 0-255 image?
about 50x
brighter
49
Our devices do not match the real world
• 10:1 photographic print (higher for glossy paper)
• 20:1 artist's paints
• 200:1 slide film
• 500:1 negative film
• 1000:1 LCD display
• 2000:1 digital SLR (at 12 bits)
HDR imaging and tonemapping are distinct
• 100000:1 real world techniques with different goals
Two challenges: HDR imaging compensates for sensor limitations
1. HDR imaging – which parts of the world do we measure in the 8-14 bits available to our sensor?
2. Tonemapping – which parts of the world do we show in the 4-10 bits available to our display?
51
52
53
54
55
Slide credits
56
57
Key idea
1. Exposure bracketing: Capture multiple LDR images at different exposures
58
Application: Photography
59
“Sunset from Rigi Kaltbad” [Wojciech Jarosz 2014]
60
“Sunset from Rigi Kaltbad” [Wojciech Jarosz 2014]
61
“Camogli Lighthouse” [Wojciech Jarosz 2012]
62
“Camogli Lighthouse” [Wojciech Jarosz 2012]
63
“Florence” [Wojciech Jarosz 2011]
64
“Florence” [Wojciech Jarosz 2011]
65
“Matterhorn and Riffelsee” [Wojciech Jarosz 2010]
66
“Matterhorn and Riffelsee” [Wojciech Jarosz 2010]
Key idea
1. Exposure bracketing: Capture multiple LDR images at different exposures
67
Multiple exposure photography
low contrast
10-6 106
image
10-6 106
real
high dynamic range world
68
Multiple exposure photography
low contrast
10-6 106
image
10-6 106
real
high dynamic range world
69
Multiple exposure photography
low contrast
10-6 106
image
10-6 106
real
high dynamic range world
70
Multiple exposure photography
low contrast
10-6 106
image
10-6 106
real
high dynamic range world
71
Multiple exposure photography
low contrast
10-6 106
image
10-6 106
real
high dynamic range world
72
Multiple exposure photography
low contrast
10-6 106
image
10-6 106
real
high dynamic range world
73
Ways to vary exposure
1. Shutter speed
3. ISO
Questions:
1. How many exposures?
2. What exposures?
76
Exposure bracketing with shutter speed
Note: shutter times usually obey a power series – each “stop” is a factor of 2
1/4, 1/8, 1/15, 1/30, 1/60, 1/125, 1/250, 1/500, 1/1000 sec
usually really is
1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024 sec
Questions:
1. How many exposures?
2. What exposures?
77
Key idea
1. Exposure bracketing: Capture multiple LDR images at different exposures
78
The image processing pipeline
The sequence of image processing operations applied by the camera’s image signal
processor (ISP) to convert a RAW image into a “conventional” image.
analog front-
end
RAW image
(mosaiced,
linear, 12-bit)
CFA white
denoising
demosaicing balance
final RGB
color tone
compression image (non-
transforms reproduction
linear, 8-bit)
79
The image processing pipeline
The sequence of image processing operations applied by the camera’s image signal
processor (ISP) to convert a RAW image into a “conventional” image.
analog front-
end
RAW image
(mosaiced,
linear, 12-bit)
CFA white
denoising
demosaicing balance
final RGB
color tone
compression image (non-
transforms reproduction
linear, 8-bit)
80
RAW images have a linear response curve
Colorchecker: Great tool for radiometric
and color calibration.
Over/under exposure
in highlights we are
limited by clipping
in shadows we are
limited by noise
RAW (linear) image formation model
Real scene flux for image pixel (x,y): Φ(x, y)
Exposure time:
t5 t4 t3 t2 t1
83
RAW (linear) image formation model
Real scene flux for image pixel (x,y): Φ(x, y)
Exposure time:
t5Scene radiance t4 Φ(x,y) reachest3 t2 at a pixel x, ty
the sensor 1
84
RAW (linear) image formation model
Real scene flux for image pixel (x,y): Φ(x, y)
Exposure time:
t5 t4 t3 t2 t1
85
RAW (linear) image formation model
Real scene flux for image pixel (x,y): Φ(x, y)
Exposure time:
t5 t4 t3 t2 t1
- -imageHDR = average(4·imageB,
imageHDR = average(4·imageB, remove-clipped(imageA))
remove-clipped(imageA))
- assumes images have been linearized
- assumes images have been linearized
3. Form a new pixel value as the weighted average of valid pixel values
t5 t4 t3 t2 t1
88
Merging RAW (linear) exposure stacks
For each pixel:
1. Find “valid” images (noise) 0.05 < pixel < 0.95 (clipping)
89
Merging RAW (linear) exposure stacks
For each pixel:
1. Find “valid” images (noise) 0.05 < pixel < 0.95 (clipping)
3. Form a new pixel value as the weighted average of valid pixel values
t5 t4 t3 t2 t1
90
Merging result (after tonemapping)
91
What if I cannot use raw?
92
Radiometric calibration
93
The image processing pipeline
• Can you foresee any problem when we switch from RAW to rendered images?
analog front-
end
RAW image
(mosaiced,
linear, 12-bit)
CFA white
denoising
demosaicing balance
final RGB
color tone
compression image (non-
transforms reproduction
linear, 8-bit)
94
The image processing pipeline
• Can you foresee any problem when we switch from RAW to rendered images?
• How do we deal with the nonlinearities?
analog front-
end
RAW image
(mosaiced,
linear, 12-bit)
CFA white
denoising
demosaicing balance
final RGB
color tone
compression image (non-
transforms reproduction
linear, 8-bit)
95
Radiometric calibration
The process of measuring the camera’s response curve. Can be done in three ways:
• Take images of scenes with different flux while keeping exposure the same.
• Take images under different exposures while keeping flux the same.
• Take images of scenes with different flux and under different exposures.
96
Same camera exposure, varying scene flux
Colorchecker: Great tool for radiometric
and color calibration.
known exposure
Different values correspond to images
All points on (the white part of) the
taken under increasing camera
target have the same reflectance.
exposure.
98
Varying both scene flux and camera exposure
You can do this using the LDR exposure stack itself.
How would you merge the non-linear images into an HDR one?
100
Non-linear image formation model
Real scene flux for image pixel (x,y): Φ(x, y)
Exposure time: ti
Inon-linear(x,y) = f[ Ilinear(x,y) ]
102
Merging non-linear exposure stacks
1. Calibrate response curve
2. Linearize images
3. Find “valid” images (noise) 0.05 < pixel < 0.95 (clipping)
103
What if I cannot measure the response curve?
104
You may find information in the image itself
105
Tone reproduction curves
The exact tone reproduction curve depends on the camera.
• Often well approximated as Lγ, for different values of the power γ (“gamma”).
• A good default is γ = 1 / 2.2.
107
The Approach
• Get pixel values Zij for image with shutter time Δtj (ith pixel location, jth image)
• Exposure is radiance integrated over time:
Eij = Ri × Dt j Þ ln Eij = ln Ri + ln Dt j
• To recover radiance Ri, we must map pixel values to log exposure: ln(Eij)= g(Zij)
[ ]
N P Z max
åå w( Zij ) ln Ri + ln Dt j - g ( Zij ) + l
i =1 j =1
2
å w( z )
z = Z min
g ¢¢( z ) 2
108
The objective
Solve for radiance R and mapping g for each of 256 pixel values to
minimize:
åå w( Z )[ln R + ln Dt - g ( Z )] + l å w( z ) g ¢¢( z )
N P Z max
2 2
ij i j ij
i =1 j =1 z = Z min
109
The Math
• Let g(z) be the discrete inverse response function
• For each pixel site i in each image j, want:
åå [ ]
N P Z max
ln Radiancei + ln Dt j - g ( Zij ) + l å g ( z )
¢¢
2 2
i =1 j =1 z = Z min
110
[4] FAUGERAS , O. Three-Dimensional Computer Vision. MIT
Press, 1993.
Matlab Code
%
[5] F ERWERDA , J. A., PATTANAIK , S. N., S HIRLEY, P., AND %
%
gsolve.m − Solve for imaging system response function
• 21 lines of code!
pp. 43–54.
[7] H ORN , B. K. P. Robot Vision. MIT Press, Cambridge, Mass.,
%
%
%
%
Arguments:
lighting guide, 7th ed. Illuminating Engineering Society, New function [g,lE]=gsolve(Z,B,l,w)
A = zeros(size(Z,1)*size(Z,2)+n+1,n+size(Z,1));
[10] K OLB , C., M ITCHELL , D., AND H ANRAHAN , P. A realis- b = zeros(size(A,1),1);
tic camera model for computer graphics. In SIGGRAPH ’95 %% Include the data−fitting equations
(1995). k = 1;
for i=1:size(Z,1)
for j=1:size(Z,2)
[11] L AVEAU , S., AND FAUGERAS , O. 3-D scene representation wij = w(Z(i,j)+1);
A(k,Z(i,j)+1) = wij; A(k,n+i) = −wij; b(k,1) = wij * B(i,j);
as a collection of images. In Proceedings of 12th International k=k+1;
end
Conference on Pattern Recognition (1994), vol. 1, pp. 689– end
691. %% Fix the curve by setting its middle value to 0
•1 •1 •1 •1 •1
•2 •2 •2 •2 •2
•3 •3 •3 •3 •3
∆t = ∆t = ∆t = ∆t = ∆t =
1/64 sec 1/16 sec 1/4 sec 1 sec 4 sec
3
value
value
Pixel value
Pixel value
Pixel
Pixel
log
log Exposure
Exposure log
log Exposure
Exposure
113
scaling terms can be adjusted by photographing a cali-
naire of known color.
Response Curve
ng virtual photographs
ed response functions can also be used to map radiance Figure 3: (a) Eleven grayscale photographs of an indoor scene ac
to pixel values for a given exposure using Equa- quired with a Kodak DCS460 digital camera, with shutter speed
process can be thought Kodak DCS460
of as taking a virtual photograph progressing in 1-stop increments from of a second to 30 seconds
Recovered response curve
ce map, in that the resulting
1/30image
to 30willsecexhibit the re-
ties of the modeled imaging system. Note that the re-
hree un- 250
ions used need not be the same response functions used
ute radi-
the original radiance map, which allows photographs
of these
ce
h map.
one imaging process to be rendered as if they were 200
ch that a 9
hixelanother.
with
value
ance val-
pixel value Z
c. If the 150
ults
qually to
rocedure
Pixel
how the results of using our algorithm to determine the
matically 100
ent light.
ve ofbea DCS460 digital camera. Eleven grayscale pho-
hould
ered down to
o a radi- resolution (Fig. 3) were taken at
the color 50
osure times ranging from
film re-
of a second to 30 seconds,
mage receiving twice the exposure of the previous one.
g a cali-
ve recovered by our algorithm from 45 pixel locations 0
−10 −5 0 5
oss the image sequence is shown in Fig. 4. Note that al- log exposure X
image arrays
radiance Figurenaturally
3: (a) Elevenproduce linear output,
grayscale photographs from
of an indoor theac-
scene log Exposure
quired with a Kodak DCS460 digital camera, with shutter speeds Figure 4: The response function of the DCS460 recovered by our al
ident
ng Equa-that the camera nonlinearly remaps the data, pre- 114
However, films are usually calibrated to respond achromatically
to a particular color of light , such as sunlight or fluorescent light.
623
In this case, the radiance values of the three channels should be
Radiance Image
scaled so that the pixel value maps to a radi-
ance with the same color ratios as . To properly model the color
response of the entire imaging process rather than just the film re-
sponse, the scaling terms can be adjusted by photographing a cali-
bration luminaire of known color.
Pixel value
pixel value Z
150
3 Results
Figures 3-5 show the results of using our algorithm to determine the 100
response curve of a DCS460 digital camera. Eleven grayscale pho-
tographs filtered down to resolution (Fig. 3) were taken at
50
f/8 with exposure times ranging from of a second to 30 seconds,
with each image receiving twice the exposure of the previous one.
The film curve recovered by our algorithm from 45 pixel locations 0
−10 −5 0 5
observed across the image sequence is shown in Fig. 4. Note that al- log exposure X
though CCD image arrays naturally produce linear output, from the log
Figure 4: The response Exposure
function of the DCS460 recovered by our
curve it is evident that the camera nonlinearly remaps the data, pre- gorithm, with the underlying data shown as light c
sumably to mimic the response curves found in film. The underlying cles. The logarithm is base .
registered data are shown as light circles underneath
the curve; some outliers are due to sensor artifacts (light horizontal
bands across some of the darker images.)
Fig. 5 shows the reconstructed high dynamic range radiance map. 115
624 Computer Vision: Algorithms and Applications, 2nd ed. (final draft, Sept. 2021)
Radiance Image
250 250
Red Green
250 250
200 200
200 200
value
value
Z Z
Z Z
value
value
value 150 150
value
150 150
pixel
pixel
Pixel
Pixel
pixel
pixel
100 100
100 100
50 50
50 50
0 0
−10
0 −5 0 5 −10
0 −5 0 5
−10 −5 log exposure X 0 5 −10 −5 log exposure X 0 5
log exposure X log exposure X
(a) (b)
log Exposure
(a)
Blue
log Exposure (b)
Red (dashed), Green (solid), and Blue (dash−dotted) curves
Blue Red (dashed), Green (solid), and Blue (dash−dotted) curves
250 250
Blue RGB
250 250
200 200
200 200
value
value
Z Z
Z Z
value
value
150 150
value
value
150 150
Pixel
Pixel
pixel
pixel
pixel
pixel
100 100
100 100
50 50
50 50
0 0
−10
0 −5 0 5 −5
0 −4 −3 −2 −1 0 1 2
−10 −5 log exposure X 0 5 −5 −4 −3 −2 −1X
log exposure 0 1 2
log Exposure
log exposure X
(c)
(c) log Exposure
log exposure X
(d)
(d) 117
Other aspects of HDR imaging
118
Relative vs absolute flux
Final fused HDR image gives flux only up to a global scale
• If we know exact flux at one point, we can convert relative HDR image
to absolute flux map
120
Basic HDR approach
1. Capture multiple LDR images at different exposures
Most modern automatic HDR solutions include an alignment step before merging
exposures
121
HDR Deghosting
• Family algorithms suggested for eliminating the artefacts
occur due to moving objects/camera and/or dynamic
backgrounds during HDR reconstruction.
• Mostly the motion is compensated by selecting or removing
moving
684 objects and
O. T. Tursun, A. O.finding
Akyüz, A. alignments
Erdem & E. Erdembetween
/ The State ofimages.
the Art in HDR Deghosting: A Survey and Evaluation
(a) A moving light source with (b) Non-deformable body motion (c) Deformable body motion (d) Deformable body motion with
high noise with large displacements occlusions
Table 1: Notation used in this survey Once f is recovered, the HDR value H(p) can be com-
122
HDR Deghosting
Okan Tarhan Tursun1 , Ahmet Oğuz Akyüz1 , Aykut Erdem2 and Erkut Erdem2
• Family algorithms suggested for eliminating the artefacts
1 Dept. of Computer Engineering, Middle East Technical University, Turkey
occur due to moving objects/camera and/or dynamic
2 Dept. of Computer Engineering, Hacettepe University, Turkey
backgrounds during HDR reconstruction.
• Mostly the motion is compensated by selecting or removing
moving objects and finding alignments between images.
123
How do we store HDR images?
• Most standard image formats store integer 8-bit images
• Some image formats store integer 12-bit or 16-bit images
• HDR images are floating point 32-bit or 64-bit images
124
How do we store HDR images?
Use specialized image formats for HDR images
32 bits
Application: image-
based relighting
126
Another way to create HDR images
127
Our devices do not match the real world
• 10:1 photographic print (higher for glossy paper)
• 20:1 artist's paints
• 200:1 slide film
• 500:1 negative film
• 1000:1 LCD display
• 2000:1 digital SLR (at 12 bits)
HDR imaging and tonemapping are distinct
• 100000:1 real world techniques with different goals
Two challenges: HDR imaging compensates for sensor limitations
1. HDR imaging – which parts of the world do we measure in the 8-14 bits available to our sensor?
2. Tonemapping – which parts of the world do we show in the 4-10 bits available to our display?
129
Tonemapping
130
How do we display our HDR images?
10-6 106
display
10-6 106
image HDR image
10-6 106
common real-world scenes
132
Linear scaling
Scale image so that maximum value equals 1.
I HDR
I display =
1 + I HDR
(exact formula more complicated)
136
Examples
photographic tonemapping linear scaling (map 10% to 1) linear scaling (map 100% to 1) 137
Compare with LDR images
tonemap
intensity
(e.g., luminance
Y in xyY)
142
Purposes of tone mapping
Technical:
- fitting a wide range of values into a small space while preserving
differences between values as much as possible
Artistic
- reproduce what the photographer/artist feels she saw
- stylize the look of a photo
143
Low-frequency intensity-only tonemapping
tonemap low-frequency
intensity component
leave high-frequency
intensity component
the same
146
Comparison
We fixed the halos without losing contrast
147
148
149
153
Tonemapping for a single image
Modern DSLR sensors capture about 3 stops of dynamic range.
• Tonemap single RAW file instead of using camera’s default rendering.
154
Some notes about HDR imaging and tonemapping
155
Our devices do not match the real world
• 10:1 photographic print (higher for glossy paper)
• 20:1 artist's paints
• 200:1 slide film
• 500:1 negative film
• 1000:1 LCD display
• 2000:1 digital SLR (at 12 bits)
HDR imaging and tonemapping are distinct
• 100000:1 real world techniques with different goals
Two challenges: HDR imaging compensates for sensor limitations
1. HDR imaging – which parts of the world do we measure in the 8-14 bits available to our sensor?
2. Tonemapping – which parts of the world do we show in the 4-10 bits available to our display?
analog front-
end
RAW image
(mosaiced,
linear, 12-bit)
CFA white
denoising
demosaicing balance
final RGB
color tone
compression image (non-
transforms reproduction
linear, 8-bit)
158
A note of caution
159
160
161
162
A note of caution
163
164
165
166
167
A note of caution
168
A note about HDR today
169
Optimal weights for HDR merging
170
Merging non-linear exposure stacks
1. Calibrate response curve
2. Linearize images
3. Find “valid” images (noise) 0.05 < pixel < 0.95 (clipping)
172
RAW (linear) image formation model
(Weighted) radiant flux for image pixel (x,y): α ⋅ Φ(x, y)
Exposure time:
t5 t4 t3 t2 t1
174
Simple estimation example
We have two independent unbiased estimators x and y of the same quantity I (e.g., pixel
intensity) with variance σ[x]2 and σ[y]2.
What does unbiased mean?
E[x] = E[y] = I
Assume we form a new estimator from the convex combination of the other two:
z = a ⋅ x + (1 – a) ⋅ y
Is the new estimator z unbiased?
175
Simple estimation example
We have two independent unbiased estimators x and y of the same quantity I (e.g., pixel
intensity) with variance σ[x]2 and σ[y]2.
What does unbiased mean?
E[x] = E[y] = I
Assume we form a new estimator from the convex combination of the other two:
z = a ⋅ x + (1 – a) ⋅ y
Is the new estimator z unbiased? → Yes, convex combination preserves unbiasedness.
E[z] = E[a ⋅ x + (1 – a) ⋅ y] = a ⋅ E[x] + (1 – a) ⋅ E[y] = I
How should we select a?
176
Simple estimation example
We have two independent unbiased estimators x and y of the same quantity I (e.g., pixel
intensity) with variance σ[x]2 and σ[y]2.
What does unbiased mean?
E[x] = E[y] = I
Assume we form a new estimator from the convex combination of the other two:
z = a ⋅ x + (1 – a) ⋅ y
Is the new estimator z unbiased? → Yes, convex combination preserves unbiasedness.
E[z] = E[a ⋅ x + (1 – a) ⋅ y] = a ⋅ E[x] + (1 – a) ⋅ E[y] = I
How should we select a? → Minimize variance (= expected squared error for unbiased
estimators).
E[(z – I) ] = E[z ] – 2 ⋅ E[z] ⋅ I + I = E[z ] – E[z] = σ[z]
2 2 2 2 2 2
177
Simple estimation example
We have two independent unbiased estimators x and y of the same quantity I (e.g., pixel
intensity) with variance σ[x]2 and σ[y]2.
What does unbiased mean?
E[x] = E[y] = I
Assume we form a new estimator from the convex combination of the other two:
z = a ⋅ x + (1 – a) ⋅ y
Is the new estimator z unbiased? → Yes, convex combination preserves unbiasedness.
E[z] = E[a ⋅ x + (1 – a) ⋅ y] = a ⋅ E[x] + (1 – a) ⋅ E[y] = I
How should we select a? → Minimize variance (= expected squared error for unbiased
estimators).
E[(z – I) ] = E[z ] – 2 ⋅ E[z] ⋅ I + I = E[z ] – E[z] = σ[z]
2 2 2 2 2 2
𝜕σ[z]2
=0
𝜕𝑎
σ[y]2 σ[x]2
⇒ 𝑎= and 1−𝑎 =
σ[x]2 +σ[y]2 σ[x]2 +σ[y]2
179
Simple estimation example
Putting it all together, the optimal linear combination of the two estimators is
σ[x]2σ[y]2 1 1
𝑧= ⋅ 𝑥+ 𝑦
σ[x] + σ[y]2 σ[x]2
2 σ[y]2
180
Simple estimation example
Putting it all together, the optimal linear combination of the two estimators is
σ[x]2σ[y]2 1 1
𝑧= ⋅ 𝑥+ 𝑦
σ[x] + σ[y]2 σ[x]2
2 σ[y]2
182
Back to HDR
Given unclipped and dark-frame-corrected intensity measurements Ii[x, y] at pixel [x, y] and
exposures ti, we can merge them optimally into a single HDR intensity I[x, y] as
$ $
1 1 1 1 1
𝐼 𝑥, 𝑦 = $ ⋅ = 𝑤𝑖 𝑥, 𝑦 𝐼𝑖 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦
∑!"# 𝑤𝑖 𝑥, 𝑦 𝑡i 1 1 2 𝑡i
!"# ∑$ !"# σ[ 𝐼 [𝑥, 𝑦]]
!"# 1 𝑡 i
𝑖
σ[ 𝑡 𝐼𝑖 [𝑥, 𝑦]]2
i
The per-pixel weights wi x, y should be selected to be inversely proportional to the variance
$
σ[ Ii[x, y]]2 at each image in the exposure stack.
%!
• How do we compute this variance?
183
Pixel noise and variance
• Recall: noise is characterized by its variance
• i.e. each pixel value comes from a true value plus some noise added
184
Sources of noise
• Photon noise
• variance proportional to signal
• dominates for dark pixels
• Read noise
• constant variance
• dominates for dark pixels
186
Back to HDR
Given unclipped and dark-frame-corrected intensity measurements Ii[x, y] at pixel [x, y] and
exposures ti, we can merge them optimally into a single HDR intensity I[x, y] as
$ $
1 1 1 1 1
𝐼 𝑥, 𝑦 = $ ⋅ = 𝑤𝑖 𝑥, 𝑦 𝐼𝑖 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦
∑!"# 𝑤𝑖 𝑥, 𝑦 𝑡i 1 1 2 𝑡i
!"# ∑$ !"# σ[ 𝐼 [𝑥, 𝑦]]
!"# 1 𝑡 i
𝑖
σ[ 𝑡 𝐼𝑖 [𝑥, 𝑦]]2
i
The per-pixel weights wi x, y should be selected to be inversely proportional to the variance
!
σ[ Ii[x, y]]2 at each image in the exposure stack.
"!
• How do we compute this variance? → Use affine noise model.
#
σ[1 𝐼𝑖 [𝑥, 𝑦]]2 = ?
!
187
Back to HDR
Given unclipped and dark-frame-corrected intensity measurements Ii[x, y] at pixel [x, y] and
exposures ti, we can merge them optimally into a single HDR intensity I[x, y] as
$ $
1 1 1 1 1
𝐼 𝑥, 𝑦 = $ ⋅ = 𝑤𝑖 𝑥, 𝑦 𝐼𝑖 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦
∑!"# 𝑤𝑖 𝑥, 𝑦 𝑡i 1 1 2 𝑡i
!"# ∑$ !"# σ[ 𝐼 [𝑥, 𝑦]]
!"# 1 𝑡 i
𝑖
σ[ 𝑡 𝐼𝑖 [𝑥, 𝑦]]2
i
The per-pixel weights wi x, y should be selected to be inversely proportional to the variance
!
σ[ Ii[x, y]]2 at each image in the exposure stack.
"!
• How do we compute this variance? → Use affine noise model.
# #
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 !
2 σ[𝐼𝑖 [𝑥, 𝑦]]2
! !
#
⇒ σ[1 𝐼𝑖 [𝑥, 𝑦]]2 = ?
!
188
Back to HDR
Given unclipped and dark-frame-corrected intensity measurements Ii[x, y] at pixel [x, y] and
exposures ti, we can merge them optimally into a single HDR intensity I[x, y] as
$ $
1 1 1 1 1
𝐼 𝑥, 𝑦 = $ ⋅ = 𝑤𝑖 𝑥, 𝑦 𝐼𝑖 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦
∑!"# 𝑤𝑖 𝑥, 𝑦 𝑡i 1 1 2 𝑡i
!"# ∑$ !"# σ[ 𝐼 [𝑥, 𝑦]]
!"# 1 𝑡 i
𝑖
σ[ 𝑡 𝐼𝑖 [𝑥, 𝑦]]2
i
The per-pixel weights wi x, y should be selected to be inversely proportional to the variance
!
σ[ Ii[x, y]]2 at each image in the exposure stack.
"!
• How do we compute this variance? → Use affine noise model.
Computing the optimal weights
# # requires:
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 ! σ[𝐼𝑖 [𝑥, 𝑦]]2
2
! ! 1. calibrated noise characteristics.
# # ' 2. knowing the radiant flux α ⋅ Φ[x, y].
⇒ σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 ! 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔 + σadd
2 2
! !
189
Back to HDR
Given unclipped and dark-frame-corrected intensity measurements Ii[x, y] at pixel [x, y] and
exposures ti, we can merge them optimally into a single HDR intensity I[x, y] as
$ $
1 1 1 1 1
𝐼 𝑥, 𝑦 = $ ⋅ = 𝑤𝑖 𝑥, 𝑦 𝐼𝑖 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦
∑!"# 𝑤𝑖 𝑥, 𝑦 𝑡i 1 1 2 𝑡i
!"# ∑$ !"# σ[ 𝐼 [𝑥, 𝑦]]
!"# 1 𝑡 i
𝑖
σ[ 𝑡 𝐼𝑖 [𝑥, 𝑦]]2
i
The per-pixel weights wi x, y should be selected to be inversely proportional to the variance
!
σ[ Ii[x, y]]2 at each image in the exposure stack.
"!
• How do we compute this variance? → Use affine noise model.
Computing the optimal weights
# # requires:
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 ! σ[𝐼𝑖 [𝑥, 𝑦]]2
2
! ! 1. calibrated noise characteristics.
# # ' 2. knowing the radiant flux α ⋅ Φ[x, y].
⇒ σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 ! 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔 + σadd
2 2
! !
This is what we wanted to estimate!
190
Simplification: only photon noise
If we assume that our measurements are dominated by photon noise, the variance
becomes:
# #
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 !
2 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔'+ σadd2 ≃ ?
! !
191
Simplification: only photon noise
If we assume that our measurements are dominated by photon noise, the variance
becomes:
# # #
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 !
2 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔'+ σ add
2 ≃ 1!
𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔 '
! !
By replacing in the merging formula and assuming only valid pixels, the HDR estimate
becomes:
$ $
1 1 1 1
𝐼 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦 = $ ⋅ = 𝐼𝑖 [𝑥, 𝑦]
1 1 ' 𝑡i ∑!"# 𝑡𝑖
∑$ !"# 𝑡 𝛼 ⋅ Φ 𝑥, 𝑦 ⋅ 𝑔 !"#
!"# 1 ' i
𝑡i 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔
192
Simplification: only photon noise
If we assume that our measurements are dominated by photon noise, the variance
becomes:
# # #
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 !
2 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔'+ σ add
2 ≃ 1!
𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔 '
! !
By replacing in the merging formula and assuming only valid pixels, the HDR estimate
becomes:
$ $
1 1 1 1
𝐼 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦 = $ ⋅ = 𝐼𝑖 [𝑥, 𝑦]
1 1 ' 𝑡i ∑!"# 𝑡𝑖
∑$ !"# 𝑡 𝛼 ⋅ Φ 𝑥, 𝑦 ⋅ 𝑔 !"#
!"# 1 ' i
𝑡i 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔
193
Simplification: only photon noise
If we assume that our measurements are dominated by photon noise, the variance
becomes:
# # #
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 !
2 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔'+ σ add
2 ≃ 1!
𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔 '
! !
By replacing in the merging formula and assuming only valid pixels, the HDR estimate
becomes:
$ $
1 1 1 1
𝐼 𝑥, 𝑦 = ⋅= 𝐼𝑖 𝑥, 𝑦 = $ ⋅ = 𝐼𝑖 [𝑥, 𝑦]
1 1 ' 𝑡i ∑!"# 𝑡𝑖
∑$ !"# 𝑡 𝛼 ⋅ Φ 𝑥, 𝑦 ⋅ 𝑔 !"#
!"# 1 ' i
𝑡i 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔
Notice that we no longer weight each image in the exposure stack by its exposure time!
194
Some comparisons
# # #
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 !
2 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔'+ σ add
2 ≃ 1!!
𝐼𝑖 [𝑥, 𝑦] ⋅ 𝑔 + σadd2
! !
196
More general case
If we cannot assume that our measurements are dominated by photon noise, we can
approximate the variance as:
# # #
σ[1 𝐼𝑖 [𝑥, 𝑦]] = 1 !
2 𝑡i ⋅ 𝛼 ⋅ Φ[𝑥, 𝑦] ⋅ 𝑔'+ σ add
2 ≃ 1!!
𝐼𝑖 [𝑥, 𝑦] ⋅ 𝑔 + σadd2
! !
197
standard weights optimal weights ground-truth
Some
comparisons
2.8 dB 14.6 dB
198
What about ISO?
199
“ground truth” SNR-optimal standard exposure
sequence bracketing
1/125 s 1/1600 s 1/6400 s 1/200 s 1/400 s 1/800 s
ISO 6400 ISO 6400 ISO 800 ISO 100 ISO 100 ISO 100
……
+15 more
input
200
Real capture results
tone-mapped merged HDR
bright region
dark region
16.2 dB
5.9 dB
200
Recap
• High dynamic range (HDR) imaging is useful, and a new aesthetic
• but is not necessary in all photographic situations
• Low dynamic range (LDR) tone mapping methods can also be applied
to HDR scenes
• but reducing very HDR scenes to 8 bits for JPEG using only global
methods is hard
• Local methods reduce large-scale luminance changes (across the
image) while preserving local contrast (across edges)
• use edge-preserving filters to avoid halos
201
Next Lecture:
Edge-aware filtering,
Gradient-domain image
processing
202