Noise and image acquisition
+ Panoramas
Fredo Durand
MIT EECS
6.815/6.865
Noise characteristics
Analyzing noise
•Camera on tripod, many pictures
•Compute mean, variance, stddev, SNR
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 brightness the same and explored the tradeoff between shutter speed and ISO
Analysis code
def analyzeNoise(imSeq):
    mean=imSeq[0].copy()
    N=len(imSeq)
    for i in xrange(1, N):
        mean+=imSeq[i]
    mean/=N
    variance=zeros(imSeq[0].shape)
    for i in xrange(N):
        diff=imSeq[i]-mean
        variance+=diff*diff
    variance/=N-1
    return mean, variance
Canon 1D mark IIN at ISO 3200
Canon 1D mark IIN at ISO 3200
Canon 1D mark IIN at ISO 3200
•Looks noisy, especially in dark areas
Canon 1D mark IIN at ISO 3200
•Denoised with 45 images (estimator of mean)
Canon 1D mark IIN at ISO 3200
•Standard deviation (some alignment issues...)
For each pixel, for each channel, compute
And display as an image
Canon 1D mark IIN at ISO 3200
•Standard deviation (some alignment issues...)
Observations:
more noise in bright image areas
Canon 1D mark IIN at ISO 3200
•log SNR -- looks a lot like the image!
Canon 1D mark IIN at ISO 3200
•log SNR -- looks a lot like the image!
even though we have more noise, 
bright areas have better SNR
Observations
•Noise is more visible in dark areas
•Noise is numerically higher in bright areas
•SNR is better in bright areas
Canon 1D mark IIN at ISO 3200
Canon 1D Mark II, ISO 100
•Lot less noisy!
Canon 1D mark IIN at ISO 3200
•Standard deviation (some alignment issues...)
Canon 1D Mark II at ISO 100
•Standard deviation (some alignment issues...)
Canon 1D mark IIN at ISO 3200
•log SNR
Canon 1D mark IIN at ISO 1600
•log SNR
Canon 1D mark IIN at ISO 400
•log SNR
Canon 1D mark IIN at ISO 100
•log SNR
Nikon D3s at 1600 ISO
Nikon D3s at 1600 ISO
Canon 1D Mark IIN at 1600 ISO
Recap and questions?
•Noise level depends on
-pixel intensity
-ISO
-color channel
-camera
Noise Origin
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
Pipeline & noise
•This is a conceptual diagram, don’t take it too literally
–e.g. the AD converter is a serious source of noise, but usually electronic noise, not quantization artifacts
•Orders of magnitude:
–# of photons per photosite : 10,000-100,000
–Electronic noise 5-30 electrons per photosite
Sensor
Gain (ISO)
A/D
Photon
noise
additive
noise
additive
noise
quantization
Photons
Digital image
ISO amplifies
•e.g. going from ISO 100 to ISO 400 amplifies by 4
•both noise & signal
•usually use high ISO when signal is low
=> worse signal/noise ratio
Sensor
Gain (ISO)
A/D
Photon
noise
additive
noise
additive
noise
quantization
small #
Photons
Digital image
Canon 1D mark IIN at ISO 3200
Canon 1D Mark II, ISO 100
•Lot less noisy!
ISO
•But, for a given signal level, and a given desired image brightness,
Sensor
Gain (ISO)
A/D
Photon
noise
additive
noise
additive
noise
quantization
small #
Photons
Digital image
ISO
•But, 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
Sensor
Gain (ISO)
A/D
Photon
noise
additive
noise
additive
noise
quantization
small #
Photons
Digital image
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
Questions?
Main noise sources
•Quantum (aka Schott/shot/Poisson/photon) noise
–Statistical fluctuation of # photons
•Additive electronic noise
–read noise: before amplification
=> worsens with higher ISO
–after amplification (at ADC level in particular)
=> same for all ISO
Sensor
Gain (ISO)
A/D
Photon
noise
additive
noise
additive
noise
quantization
Photons
Digital image
Main noise sources
•Quantum (aka Schott/shot/Poisson/photon) noise
–Statistical fluctuation of # photons
•Additive electronic noise
–read noise: before amplification
=> worsens with higher ISO
–after amplification (at ADC level in particular)
=> same for all ISO
•Misc.
–thermal (mostly for long exposure)
–various fixed pattern issues
Photon noise
•Say the average flux of Photons over the sensor is, 100 photons during the exposure time
–With random fluctuation, we might get 96, or maybe 101, maybe 105.
•Extreme case: the average flux is 0.5 photons during the exposure:
–We might get 0 or 1
•The amount of fluctuation grows with the average rate, but not as fast: square root.
–absolute noise increases with intensity
–relative noise decreases
clarkvision.com
Photon noise (simulation)
•Going from left to right, the mean number of photons per pixel over the whole image is (top row) 0.001, 0.01, 0.1 (middle row) 1.0, 10.0, 100.0
Great ref on noise
•Noise, Dynamic Range and Bit Depth in Digital SLRs
•by Emil Martinec © 2008
Canon 1D mark IIN at ISO 3200
•log SNR - dominated by Poisson, ~sqrt(image)
Well capacity & pixel size
•Well capacity: max number of electro per photosite
•Bigger pixel is better:
–reduce Photon noise
–increase electronic signal, need less gain
•Photometric limits for digital camera systems
•punchline: we’re pretty close to the physical limits, noise is dominated by the number of photons
Recap: Main noise sources
•Quantum (aka Schott/shot/Poisson/photon) noise
–srqt(#photons)
–dominates for brighter pixels
•Additive electronic noise
–read noise: before amplification
=> worsens with higher ISO
–after amplification (at ADC level in particular)
=> same for all ISO
–usually dominates for dark pixels
•Misc.
–thermal (mostly for long exposure)
–various fixed pattern issues
Different regimes
•For bright pixels (in fact, most pixels),
photon noise dominates
•For dark pixels: electronic noise dominates
•For low ISO, post-gain noise dominates
•For high ISO, pre-gain noise dominates
•For long exposures, thermal noise kicks in
Factors that influence noise
•Pixel pitch (8 microns: good, 2 microns: bad)
•Area of the photosite actually photosensitive
•Microlens that focus light on that photosensitive area
•Quality of electronics
–Analog to Digital converter, power supply
•Temperature
–CCDs for Astronomy are cooled
Noise & quantization
•Note: quantization is NOT the limiting factor.
Instead, the well capacity and noise are.
–14 bits does not necessarily mean more dynamic range than 12 bits
Questions
Digital sensors are awesome
•Nikon D3s at f/2.8, 8 sec at ISO 6400
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.
Brain teaser 2
•One long exposure
•multiple shorter exposures
Recap: Digital photography pipeline
•Photosites transform photons into charge (electrons)
•Gets amplified (depending on ISO setting)
•Analog to digital converter
Stop here when shooting RAW
•Demosaicing
•Denoising
•Color space conversion (from sensor to sRGB)
•White balance
•Response curve, color enhancement
•Gamma encoding
•Quantized and recorded as JPEG
–DCT, quantization based on CSF, entropy coding
Well, some cameras apply some processing such as denoising to the RAW data
Non-linearities
Non-linearities at the end
•We don’t exactly observe the true value plus a zero-mean noise
•Because of sensor non-linearities: clamped at 0 and max
•Consequence:
-Denoising by averaging can give dark regions that are too bright
•Canon trick: they add a constant offset to the sensor signal to make sure the noise is zero-mean
References
Panoramas
Applied homographies
Applied homographies
Panoramas and Homographies
Fredo Durand
MIT EECS 6.815/6.865
Motivation
Panorama: virtual wide angle
Similar to HDR
•Medium is limited (range, field of view)
•Take multiple images
•Merge
An old idea
This image by the firm of Maison Bonfils depicts the city of Beirut, Lebanon, sometime in the last third of the 19th century. Maison Bonfils was the extraordinarily prolific venture of the French photographer Félix Bonfils (1831-85), his wife Marie-Lydie Cabanis Bonfils (1837-1918), and their son, Adrien Bonfils (1861-1928). The Bonfils moved to Beirut in 1867 and, over the next five decades, their firm produced one of the world's most important bodies of photographic work about the Middle East. Maison Bonfils was known for landscape photographs, panoramas, biblical scenes, and posed “ethnographic” portraits. The family’s marketing acumen and commercial sense helped make their photographs known around the world. “Panoramic” photographs employ a variety of techniques to create a wide angle of view. This “panoramic view” is composed of four aerial photographs set together to give the viewer a broader image than would have been practical with a single photograph.
http://en.wikipedia.org/wiki/File:%D8%A8%D9%8A%D8%B1%D9%88%D8%AA-%D8%A7%D9%84%D9%82%D8%B1%D9%86_%D9%A1%D9%A9.jpg
Old panos, modern viewer
Overview
Today
•The user gives us 4 correspondences
•We reproject one image to match the other one
•Creates a wider angle view
Later
•Automagic correspondences
-corner detection
-patch descriptor
•Nice blending
-smooth transition
-2 scale
Overview
•Today: Manual panorama
-perspective and image reprojection
-Homogenous coordinates and homographies
-Inferring homography from correspondences
•Automatic panorama
•Nice blending
Reprojection
Virtual wide angle
•Take N images in different directions
•Deduce the image that would have been taken by a wider angle lens
•…but wait, why should this work at all?
-What about the 3D geometry of the scene?
-Why aren’t we using it?
Simplified projection model
A pencil of rays contains all views
real
camera
synthetic
camera
Can generate any synthetic camera view
as long as it has the same center of projection!
viewpoint
Entrance pupil
•When camera is rotated around entrance pupil ,
there is no parallax
–That is, if two 3D points are superimposed for one orientation, they remain superimposed after rotation
•Finding the entrance pupil is painful
–and it’s often incorrectly called nodal point
Recap
•When we only rotate the camera (around nodal point) depth does not matter
•It only performs a 2D warp
–one-to-one mapping of the 2D plane
–plus of course reveals stuff that was outside the field of view
•Now we just need to figure out this mapping
real
camera
synthetic
camera
Aligning images
–We have established that pairs of images from the same viewpoint can be aligned through a simple 2D spatial transformation (warp).
–What kind of transformation?
Aligning images: translation
Translations are not enough to align the images
left on top
right on top
Recap
•We are looking for the 2D mapping that corresponds to a 3D rotation of the camera
•We need to understand perspective projection
Spoiler
•There is a simple transformation
from x,y in one image to x’,y’ in the other one
•Simple matrix multiplication+ division
•No depth required
p
p’
H
Roadmap
Goal: cut the (3d) middleman
Questions
Projective geometry
Simple Perspective Projection
•Project all points to the z = 1 plane, viewpoint at
the origin:
Simple Perspective Projection
•Project all points to the z = 1 plane, viewpoint at
the origin:
•Can we represent this
with a matrix?
(x’,y’)
(x,y,z)
–x’=x/z
–y’=y/z
z=1
–not directly (division)
–but we can cheat...
–add a third coordinate to the result
–interpret as : we always divide by 3rd coordinate
–see in a few slide...
3D rotation
•We observe point x, y, z with camera PP1
–first image of our pano
(x’,y’,1)
(x,y,z)
PP1
3D rotation
•We observe point x, y, z with camera PP1
–first image of our pano
•Now we rotate the 3D camera to PP2
–second image of our pano
•What is the new 2D projection?
–i.e. where does the a point from the first image reproject into the second one?
(x’,y’,1)
(x,y,z)
PP1
PP2
3D rotation
•Rotating the camera is the same as rotating the world in the opposite direction
•To project a (x,y,z) wrt
rotated camera:
–Apply rotation R-1 to (x,y, z)
–Apply projection division
(x’’,y’’, 1)
R(x,y,z)
rotate
3D rotation: Pano case
•Each image has a different rotation Ri
•project  (x,y,z) wrt camera rotated by Ri:
–Apply rotation Ri-1 to (x,y, z)
–Apply projection division
•Now we understand how to go from the 3D world to individual pano input images
–We now need to go directly from 2D input to another one
(x’’,y’’, 1)
R(x,y,z)
rotate
Recap
•canonical projection = division by z
•For other direction, just apply 3D rotation first
•But... this applies only when we know z
–And for panorama stitching, we don’t
–What are we going to do?Are we in big trouble? Should we give up? Buy a 3D scanner? Cancel assignment 6?
Questions
Unknown z
Points that project on the same x,y
x
z
z=1
Project to different image?
x
z
z=1
Rotate
x
z
z=1
Rotate
x
z
z=1
Divide by z
x
z
z=1
x
z
z=1
Project to different image
–It doesn’t depend on z
–All points that project to the same x,y reproject onto the same x’,y’
–after perspective division
Back to pano problem
•We want to know how points at x,y in the first image get reprojected onto the rotated second image
–problem: we don’t know their z
x
z
z=1
Back to pano problem
x
z
z=1
•We want to know how points at x,y in the first image get reprojected onto the rotated second image
–problem: we don’t know their z
–BUT ID DOESN’T DEPEND ON Z!!!!!!
–LET”S PICK AN ARBITRARY Z=1
(x,y,1)
Project to different image?
x
z
z=1
Rotate
x
z
z=1
•Apply R to vector (x, y, 1)
Rotate
x
z
z=1
•Apply R to vector (x, y, 1)
Rotate
x
z
z=1
•Apply R to vector (x, y, 1)
•divide resulting x’, y’ by resulting z’
Bottomline
•The transformation from one 2D image to a rotated image of the same scene is a 3x3 matrix H applied to x,y,1 followed by a  division by z’
–called a homography
•Now the only problem is that we usually don’t know H
Today
•The user gives us 4 correspondences
•Use regression to compute the matrix
Questions?
Homogenous coordinates
1D homogeneous coordinates
•Add one dimension to make life simpler
•(x, w) represent point x/w
x
w
w=1
Other illustration: 1D homography
•Reproject to different line
x
w
w=1
1D homography
•Reproject to different line
w=1
x
w
1D homography
•Reproject to different line
•Equivalent to rotating 2D points
reprojection is linear in homogeneous coordinates
–and independent of depth
w=1
x
w
Homogenous coordinates
•Representation of 2D points using 3 coordinates
•(x, y, w) represents (x/w, y/w)
-Homogenous points are interpreted as Euclidean coordinates by dividing by the last coordinate
•Motivations:
-perspective transforms
-Make translations linear
-Duality with hyperplanes.
Homogeneous coordinate
•represent 2D points with 3 numbers
•(x, y, w) represents (x/w, y/w)
•Allows us to represent projective transforms
•Nice thing: projecting onto plane z=1  is just the strict interpretation of homogeneous coordinates
•Yes, you can view this as a notation trick
–But math is all about smart notations
•Homogenous coordinates are central in computer graphics and machine vision
Scale invariant
•All points (wx, wy, w) for any non-zero w represent the same Euclidean point
Extra profit
•Homogenous coordinates allow us to represent 2D translations as matrices