Sensors & Demosaicing
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 Sensors & Demosaicing Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu Todays agenda How do cameras record light? How do cameras
Sensors & Demosaicing
Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu
CS 89.15/189.5, Fall 2015
How do cameras record light? How do cameras record color? How can we transform that into color images? How can we display those properly?
CS 89/189: Computational Photography, Fall 2015 2
every camera uses different algorithms the processing order may vary most of it is proprietary
CS 89/189: Computational Photography, Fall 2015 3
sensor analog-to-digital conversion (ADC) processing: demosaicing, tone/ color mapping, white balancing, denoising & sharpening, compression storage
After a slide by Marc Levoy
CS 89/189: Computational Photography, Fall 2015 4
sensor analog-to-digital conversion (ADC) processing: demosaicing, tone/ color mapping, white balancing, denoising & sharpening, compression storage
After a slide by Marc Levoy Canon 21 Mpix CMOS sensor Canon DIGIC 4 processor Compact Flash card
When a photon strikes a material, an electron may be emitted
depends on its wavelength
CS 89/189: Computational Photography, Fall 2015 5
Ephoton = h × c λ
After a slide by Marc Levoy
(wikipedia)
Not all photons will produce an electron
device
CS 89/189: Computational Photography, Fall 2015 6
QE = # electrons # photons
Hubble Space Telescope Camera 2 back-illuminated CMOS (Sony) After a slide by Marc Levoy
The current from one electron is small (10–100 fA)
(pixel area × exposure time)
Typical pixel sizes:
CS 89/189: Computational Photography, Fall 2015 7 After a slide by Marc Levoy
How many electrons can a pixel hold?
(but fill factor is important)
Too many photons causes saturation
range between the brightest scene feature that won’t saturate and the darkest that isn’t too noisy
CS 89/189: Computational Photography, Fall 2015 8 After a slide by Marc Levoy
Charge spilling over to nearby pixels
sensors
image artifacts
CS 89/189: Computational Photography, Fall 2015 9
(ccd-sensor.de)
After a slide by Marc Levoy
CCD: charge-coupled device
CMOS: complementary metal-oxide semiconductor
CS 89/189: Computational Photography, Fall 2015 10 After a slide by M. Levoy & S. Marschner
CS 89/189: Computational Photography, Fall 2015
11 Samsung white paper, Current Status and Future Perspectives of CMOS Image Sensor After a slide by Steve Marschner
Side effect of readout on CCD sensors
CS 89/189: Computational Photography, Fall 2015 12 CMOS CCD
(dvxuser.com) (dvxuser.com)
After a slide by Marc Levoy
CS 89/189: Computational Photography, Fall 2015 13 (maxim-ic.com) After a slide by Marc Levoy
Convert analog signal to digital values Recent sensors have one ADC per column of pixels Must output more bits than JPEG stores (due to gamma)
stored in a JPEG file includes a step called gamma correction, which has the form output = inputγ (0.0 ≤ input ≤ 1.0)
for a smooth gray ramp to fill each of these 256 buckets, the camera’s ADC needs to output ≥ ~10 bits; otherwise, dark parts of the ramp will exhibit banding after applying gamma correction and re-quantizing
CS 89/189: Computational Photography, Fall 2015 14
Fraction of sensor surface available to collect photons
After a slide by Marc Levoy
Front illuminated
Back illuminated
photosensors directly
CMOS sensors (iPhone 5)
CS 89/189: Computational Photography, Fall 2015 15 After a slide by Steve Marschner
Integrating light over an area at each pixel instead of point sampling serves two functions:
Microlenses gather more light and improve the prefilter
roughly equal to the pixel spacing
Antialiasing filters are typically added to further reduce aliasing
CS 89/189: Computational Photography, Fall 2015 16 After a slide by Marc Levoy
“hot rodding” your digital camera ($450 + shipping)
CS 89/189: Computational Photography, Fall 2015 17 anti-aliasing filter removed normal After a slide by Marc Levoy
“hot rodding” your digital camera ($450 + shipping)
CS 89/189: Computational Photography, Fall 2015 18 anti-aliasing filter removed normal After a slide by Marc Levoy
Nikon D800 (aa-filter) Nikon D800E (no aa-filter)
photons strike a sensor and are converted to electrons
quantum efficiency and pixel size
sensors are typically CCD or CMOS
CCDs can suffer smearing
integrating light over an area serves two functions
dynamic range
prefilter, to avoid aliasing
spacing, use microlenses
use an antialiasing filter
integrating light over time serves the same two functions
produce motion blur
CS 89/189: Computational Photography, Fall 2015 20
Problem: a photosite can record only
We need 3 numbers for color What can we do?
CS 89/189: Computational Photography, Fall 2015 22 CMOS sensor
Digital sensors are sensitive to all (visible) wavelengths
http://en.wikipedia.org/wiki/Image_sensor http://en.wikipedia.org/wiki/Active_pixel_sensor http://en.wikipedia.org/wiki/Charge-coupled_device
Obtain color measurement using different color filters
CS 89/189: Computational Photography, Fall 2015 CMOS sensor 23 After a slide by Matthias Zwicker
CS 89/189: Computational Photography, Fall 2015
24
Scan 3 times (temporal multiplexing) Use 3 detectors (3-ccd camera) Use offset color samples (spatial multiplexing) Multiplex in depth (Tripack film, Foveon) Interferences (Lipmann)
CS 89/189: Computational Photography, Fall 2015 25 After a slide by Frédo Durand
Examples:
Pros:
Cons
CS 89/189: Computational Photography, Fall 2015 26 After a slide by Frédo Durand
Photographer to the Tzar, 1863–1944 Shot sequentially through R, G, B filters Printing technology not available, but could project w/ RGB filters! Entire collection available: http://www.loc.gov/exhibits/empire/ Assignment 3
CS 89/189: Computational Photography, Fall 2015 27 After a slide by Frédo Durand
Sergey Prokudin-Gorsky, Alim Khan, emir of Bukhara (1911)
Sergey Prokudin-Gorsky, Pinkhus Karlinskii, Supervisor of the Chernigov Floodgate (1919)
Temporal multiplexing DLP projector
Digital_Light_Processing
CS 89/189: Computational Photography, Fall 2015 31 After a slide by Matthias Zwicker
High-end 3-CCD video cameras Use separation prisms
Pros
Cons
CS 89/189: Computational Photography, Fall 2015 32
Trichroic beam splitter prism http://en.wikipedia.org/wiki/3CCD
Philips 3CCD imaging block
After a slide by F. Durand & M. Zwicker
Technicolor
cumbersome printing process
CS 89/189: Computational Photography, Fall 2015 33
Wizard of Oz (1939)
After a slide by Steve Marschner
Human eye (cone mosaic), older color film, bayer mosaic/CFA (color filter array) Most still cameras, most cheap camcorder, some high-end video cameras (RED) Pros
Cons
CS 89/189: Computational Photography, Fall 2015 34 After a slide by Frédo Durand
Bayer filter
2x2 pattern
Other mosaics exist, but not as widespread
CS 89/189: Computational Photography, Fall 2015 35
Spatial multiplexing
CS 89/189: Computational Photography, Fall 2015 36 http://en.wikipedia.org/wiki/RGB_color_model
CS 89/189: Computational Photography, Fall 2015 37
From Panasonic
3-ccd with prisms + spatial multiplexing The 3 ccds are shifted by 1/2 pixel to provided resolution increase
res, shifted to get HD)
After a slide by Frédo Durand
http://www.petapixel.com/2011/05/26/hasselblad- h4d-200ms-shoots-200mp-photos-with-a-50mp-sensor/
CS 89/189: Computational Photography, Fall 2015 38 After a slide by Frédo Durand
Depth multiplexing (Foveon X3 sensor)
CS 89/189: Computational Photography, Fall 2015 39
Leverage difference in absorption per wavelength Pros
Cons
multiplied by matrix to get RGB)
because shallow blue layer)
After a slide by Frédo Durand
Good old color film (tripack)
CS 89/189: Computational Photography, Fall 2015 40 After a slide by Frédo Durand
Metal mirror to create interferences
CS 89/189: Computational Photography, Fall 2015 41 http://nobelprize.org/nobel_prizes/physics/articles/biedermann/index.html After a slide by Frédo Durand
Metal mirror to create interferences
Pros
Cons
CS 89/189: Computational Photography, Fall 2015 42 'Saint-Maxime'', 1891-1899 Photographer: Gabriel Lippmann After a slide by Frédo Durand
Scan 3 times (temporal multiplexing) Use 3 detectors (3-ccd camera) Use offset color samples (spatial multiplexing) Multiplex in depth (Tripack film, Foveon) Interferences (Lipmann)
CS 89/189: Computational Photography, Fall 2015 43 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015
45 http://www.currentprotocols.com/WileyCDA/CPUnit/refId-ns0204.html After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015
46
By kevincollins123
http://www.flickr.com/photos/kevincollins123/4584180753/ After a slide by Frédo Durand
Each photosite has a different color filter
CS 89/189: Computational Photography, Fall 2015 47
Which one is the upper left color is arbitrary and depends on the camera
After a slide by Frédo Durand
Why more green?
lattices don’t like odd numbers
perception of luminance
CS 89/189: Computational Photography, Fall 2015 48 After a slide by Frédo Durand
Straight measurement from sensor
Each photosite has only one value
Usually 12-14 bits per pixel Linear encoding
Can be read and converted using dcraw
CS 89/189: Computational Photography, Fall 2015 49 After a slide by Frédo Durand
After a slide by Frédo Durand
After a slide by Steve Marschner
After a slide by Steve Marschner After a slide by Steve Marschner
Interpolate missing values
CS 89/189: Computational Photography, Fall 2015 54
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
After a slide by Frédo Durand
Simplest solution: treat each block of 2x2 as a pixel
CS 89/189: Computational Photography, Fall 2015 55 After a slide by F. Durand & S. Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
Average pixels in groups that all have the same “center
CS 89/189: Computational Photography, Fall 2015 58
? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
After a slide by Steve Marschner
Average pixels in groups that all have the same “center
CS 89/189: Computational Photography, Fall 2015 59
? ? ? ? ? O ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ?
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
Average the 4 or 2 nearest neighbors (linear/tent kernel)
CS 89/189: Computational Photography, Fall 2015 63
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
After a slide by Frédo Durand
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
Smoother kernels can also be used (e.g. bicubic) but need wider support
CS 89/189: Computational Photography, Fall 2015 68
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
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
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Imagine a black-on-white corner Let’s focus on the green channel for now
CS 89/189: Computational Photography, Fall 2015 72 After a slide by Frédo Durand
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Imagine a black-on-white corner Let’s focus on the green channel for now
CS 89/189: Computational Photography, Fall 2015 73
1 1 1 1 1 1 1 1 1 1
After a slide by Frédo Durand
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Imagine a black-on-white corner Let’s focus on the green channel for now
CS 89/189: Computational Photography, Fall 2015 74
1 1 1 1 1 1 1 1 1 1 .25 1 1 .75 1 .25 1 1 .25 .25 .75 1 1 .75 1 .75 1 1 1 1 1 1 1 1
After a slide by Frédo Durand
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Imagine a black-on-white corner Let’s focus on the green channel for now
CS 89/189: Computational Photography, Fall 2015 75
1 1 1 1 1 1 1 1 1 1 .25 1 1 .75 1 .25 1 1 .25 .25 .75 1 1 .75 1 .75 1 1 1 1 1 1 1 1
After a slide by Frédo Durand
After a slide by Frédo Durand
After a slide by Frédo Durand
Take into account structure in image
Interpolate along preferred direction
neighbors
CS 89/189: Computational Photography, Fall 2015 79
1 1 1 1 1 1 1 1 1 1
After a slide by Frédo Durand
Look at the similarity of recorded neighbors
Called edge-based demosaicing
CS 89/189: Computational Photography, Fall 2015 80
1 1 1 1 1 1 1 1 1 1
After a slide by Frédo Durand
After a slide by Frédo Durand
After a slide by Frédo Durand
What do we do with red and blue? We could apply the edge-based principle But we’re missing more information But color transitions might be shifted
CS 89/189: Computational Photography, Fall 2015 84 After a slide by Frédo Durand
? ? ? ?
Notion of edges unclear for pixels in empty rows/columns
CS 89/189: Computational Photography, Fall 2015 85 After a slide by Frédo Durand
Even if we could do a decent job for each channel, the channels don’t line up
CS 89/189: Computational Photography, Fall 2015 86 After a slide by Frédo Durand
Even if we could do a decent job for each channel, the channels don’t line up
CS 89/189: Computational Photography, Fall 2015 87
+ +
After a slide by Frédo Durand
Even if we could do a decent job for each channel, the channels don’t line up
CS 89/189: Computational Photography, Fall 2015 88
Bad color fringes!
After a slide by Frédo Durand
After a slide by Frédo Durand
Green is a better color channel
Do the best job you can and get high resolution from green Then use green to guide red & blue interpolation
CS 89/189: Computational Photography, Fall 2015 91 After a slide by Frédo Durand
Interpolate green
For recorded red pixels
At empty pixels
Same for blue
CS 89/189: Computational Photography, Fall 2015 92 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 93 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 94 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 95 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 96
Zero everywhere!
After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 97
Zero everywhere!
After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 98 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015 99 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
After a slide by Frédo Durand
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
After a slide by Steve Marschner
CS 89/189: Computational Photography, Fall 2015 110
Interpolate ratio
CS 89/189: Computational Photography, Fall 2015 111 After a slide by Frédo Durand
http://www.luminous-landscape.com/contents/DNG- Recover-Edges.shtml http://www.luminous-landscape.com/forum/index.php? topic=51328.0
CS 89/189: Computational Photography, Fall 2015 112 After a slide by Frédo Durand
http://research.microsoft.com/en-us/ UM/people/yasumat/papers/ lowlight_CVPR11.pdf
CS 89/189: Computational Photography, Fall 2015 113 After a slide by Frédo Durand
http://research.microsoft.com/en-us/UM/people/ yasumat/papers/cvpr2010_Takamatsu.pdf
CS 89/189: Computational Photography, Fall 2015 114 After a slide by Frédo Durand
http://www.csee.wvu.edu/~xinl/papers/demosaicing_survey.pdf http://www.unc.edu/~rjean/demosaicing/demosaicing.pdf http://www.pages.drexel.edu/~par24/rawhistogram/ 40D_Demosaicing/40D_DemosaicingArtifacts.html http://www.guillermoluijk.com/tutorial/dcraw/index_en.htm http://www.cambridgeincolour.com/tutorials/RAW-file-format.htm http://www.cambridgeincolour.com/tutorials/camera-sensors.htm
CS 89/189: Computational Photography, Fall 2015 115 After a slide by Frédo Durand
Measured pixel values are not CIE RGB values! Remap to appropriate colorspace using transformation derived from response curves
specific)
CS 89/189: Computational Photography, Fall 2015 117
Sensor is like eye
Problems with measured data
CS 89/189: Computational Photography, Fall 2015 118 After a slide by Steve Marschner
CS 89/189: Computational Photography, Fall 2015 119
sensor analog-to-digital conversion (ADC) processing: demosaicing, tone/ color mapping, white balancing, denoising & sharpening, compression storage
After a slide by Marc Levoy
Like eye, key property is the spectral sensitivity curves
CS 89/189: Computational Photography, Fall 2015 120
0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 400 500 600 700 800 900 1000 Absolute Quantum Efficiency Wavelength (nm)
With clear cover glass
KAI-2093 Image Sensor In real cameras there will be a filter to block infrared
After a slide by Steve Marschner
CS 89/189: Computational Photography, Fall 2015 121
span of camera’s spectral response functions camera metamer
spectrum s span of eye’s spectral response functions s’ visual metamer
Given camera response, guess corresponding visual response This guess has to involve assumptions about which reflectance spectra are more likely Mathematical approach:
Or, more often, just derive a transformation empirically
After a slide by Steve Marschner
Assume spectrum s is a combination of three spectra Work out what combination it is
CS 89/189: Computational Photography, Fall 2015 122
|
s
|
=
| | |
s1 s2 s3
| | |
a1 a2 a3 R G B = rR rG rB
| | |
s1 s2 s3
| | |
a1 a2 a3 a1 a2 a3 = rR rG rB
| | |
s1 s2 s3
| | |
−1
R G B
After a slide by Steve Marschner
rR rG rB
| | |
s1 s2 s3
| | |
−1
R G B
Project that combination onto visual response
S M L = rS rM rL
| | |
s1 s2 s3
| | |
Assume spectrum s is a combination of three spectra Work out what combination it is
CS 89/189: Computational Photography, Fall 2015 123
|
s
|
=
| | |
s1 s2 s3
| | |
a1 a2 a3 a1 a2 a3 = rR rG rB
| | |
s1 s2 s3
| | |
−1
R G B
Project that combination onto visual response
After a slide by Steve Marschner
rR rG rB
| | |
s1 s2 s3
| | |
−1
R G B
Empirical color transformation
Baseline method: use Macbeth Color Checker
(these days you buy the MCC from X-Rite)
Procedure
approximately maps the camera responses to the correct answers
CS 89/189: Computational Photography, Fall 2015 124
min
M kCmacbeth M Ccamerak
3×3 3×24 3×24
After a slide by Steve Marschner
Problem with previous slide
Solutions?
von Kries hypothesis: eye accounts for illuminant by simply scaling the three cone signals separately
CS 89/189: Computational Photography, Fall 2015 125
Calibrate your color matrix using a carefully white-balanced image
(then M will leave neutral colors exactly alone)
For each photograph:
CS 89/189: Computational Photography, Fall 2015 126
Frédo Durand Steve Marschner Matthias Zwicker Marc Levoy
CS 89/189: Computational Photography, Fall 2015 130