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 Sensors & Demosaicing Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu Todays agenda How do cameras record light? How do cameras


slide-1
SLIDE 1

Sensors & Demosaicing

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

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

slide-3
SLIDE 3

Camera pixel pipeline

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

slide-4
SLIDE 4

Example pipeline

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

slide-5
SLIDE 5

The photoelectric effect

When a photon strikes a material, an electron may be emitted

  • depends on the photon’s energy, which

depends on its wavelength

  • there is no notion of “brighter photons”,

  • nly more or fewer of them

CS 89/189: Computational Photography, Fall 2015 5

Ephoton = h × c λ

After a slide by Marc Levoy

(wikipedia)

slide-6
SLIDE 6

Quantum efficiency

Not all photons will produce an electron

  • depends on quantum efficiency of the

device

  • human vision: ~15%
  • typical digital camera: < 50%
  • best back-thinned CCD: > 90%

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

slide-7
SLIDE 7

Pixel size

The current from one electron is small
 (10–100 fA)

  • so integrate over space and time


(pixel area × exposure time)

  • larger pixel × longer exposure means more accurate measure

Typical pixel sizes:

  • iPhone 5s (4.89×3.67mm@3264×2448pixels) = 1.5μ×1.5μ = 2.25μ2
  • Canon 5D II (36.00×24.00mm@5616×3744pixels) = 6.4μ×6.4μ = 41μ2

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

slide-8
SLIDE 8

Full well capacity

How many electrons can a pixel hold?

  • depends mainly on the size of the pixel

(but fill factor is important)

Too many photons causes saturation

  • larger capacity leads to higher dynamic

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

slide-9
SLIDE 9

Blooming

Charge spilling over to nearby pixels

  • can happen on CCD and CMOS

sensors

  • don’t confuse with glare or other

image artifacts

CS 89/189: Computational Photography, Fall 2015 9

(ccd-sensor.de)

After a slide by Marc Levoy

slide-10
SLIDE 10

CMOS vs CCD sensors

CCD: charge-coupled device

  • oldest solid-state image sensor technology
  • charge shifted along columns to an output amplifier
  • highest image quality, but not as flexible or cheap

CMOS: complementary metal-oxide semiconductor

  • newer, currently taking over
  • each pixel has own charge amplifier, read out by row/column addressing
  • same process used for CPUs and other VLSI chips
  • low power, but noisy (but getting better)

CS 89/189: Computational Photography, Fall 2015 10 After a slide by M. Levoy & S. Marschner

slide-11
SLIDE 11

CS 89/189: Computational Photography, Fall 2015

Market trend

11 Samsung white paper, Current Status and Future Perspectives of CMOS Image Sensor After a slide by Steve Marschner

slide-12
SLIDE 12

Smearing

Side effect of readout on CCD sensors

  • along columns; looks different than bloom
  • only happens if pixels saturate
  • doesn’t happen on CMOS sensors

CS 89/189: Computational Photography, Fall 2015 12 CMOS CCD

(dvxuser.com) (dvxuser.com)

After a slide by Marc Levoy

slide-13
SLIDE 13

Analog to digital conversion (ADC)

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)

  • converting ADC values (as stored in a RAW file) to the values

stored in a JPEG file includes a step called gamma correction, which has the form output = inputγ (0.0 ≤ input ≤ 1.0)

  • since JPEG files only store 8 bits/pixel per channel, in order

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

slide-14
SLIDE 14

CS 89/189: Computational Photography, Fall 2015 14

Fill factor

Fraction of sensor surface available to collect photons

  • can be improved using per-pixel microlenses
  • n a (front-illuminated) CMOS sensor
  • n a CCD sensor

After a slide by Marc Levoy

slide-15
SLIDE 15

Front vs. back illumination

Front illuminated

  • conventional design has interconnects and circuitry in front
  • causes reduced fill factor and QE (particularly for blue)

Back illuminated

  • originally an esoteric product for astronomy
  • grind away back of chip and illuminate the


photosensors directly

  • now becoming popular in small-format


CMOS sensors (iPhone 5)

CS 89/189: Computational Photography, Fall 2015 15 After a slide by Steve Marschner

slide-16
SLIDE 16

Spatial prefiltering

Integrating light over an area at each pixel instead of point sampling serves two functions:

  • 1. captures more photons, to improve dynamic range
  • 2. convolves the image with a prefilter, to avoid aliasing

Microlenses gather more light and improve the prefilter

  • microlenses ensure that the spatial prefilter is a 2D rect of width

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

slide-17
SLIDE 17

Removing the antialiasing filter

“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

slide-18
SLIDE 18

“hot rodding” your digital camera ($450 + shipping)

Removing the antialiasing filter

CS 89/189: Computational Photography, Fall 2015 18 anti-aliasing filter removed normal After a slide by Marc Levoy

slide-19
SLIDE 19

Nikon D800 (aa-filter) Nikon D800E (no aa-filter)

slide-20
SLIDE 20

Recap

photons strike a sensor and are converted to electrons

  • performance factors include

quantum efficiency and pixel size

sensors are typically CCD or CMOS

  • both can suffer blooming; only

CCDs can suffer smearing

integrating light over an area serves two functions

  • capturing more photons, to improve

dynamic range

  • convolving the image with a

prefilter, to avoid aliasing

  • to ensure that the area spans pixel

spacing, use microlenses

  • to improve further on the prefilter,

use an antialiasing filter

integrating light over time serves the same two functions

  • captures more photons, but may

produce motion blur

CS 89/189: Computational Photography, Fall 2015 20

slide-21
SLIDE 21

Color acquisition

slide-22
SLIDE 22

Sensing color images

Problem: a photosite can record only

  • ne number

We need 3 numbers for color What can we do?

CS 89/189: Computational Photography, Fall 2015 22 CMOS sensor

slide-23
SLIDE 23

Sensing color images

Digital sensors are sensitive to all
 (visible) wavelengths

  • For details see:


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

  • Color filters play same role as response curves of photoreceptors
  • Absorb part of the spectrum

CS 89/189: Computational Photography, Fall 2015 CMOS sensor 23 After a slide by Matthias Zwicker

slide-24
SLIDE 24

CS 89/189: Computational Photography, Fall 2015

Infrared capture demo

24

slide-25
SLIDE 25

Approaches to sensing color

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

slide-26
SLIDE 26

Temporal multiplexing

Examples:

  • Drum scanners
  • Flat-bed scanners
  • Maxwell, Russian photographs from 1900’s

Pros:

  • 3 real values per pixel
  • Can use a single sensor

Cons

  • Only for static scenes, slow

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

slide-27
SLIDE 27

Sergey Prokudin-Gorsky

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

slide-28
SLIDE 28

Sergey Prokudin-Gorsky,
 Alim Khan,
 emir of Bukhara (1911)

slide-29
SLIDE 29

Sergey Prokudin-Gorsky, Pinkhus Karlinskii, Supervisor of the Chernigov Floodgate (1919)

slide-30
SLIDE 30
slide-31
SLIDE 31

Color displays

Temporal multiplexing DLP projector

  • http://en.wikipedia.org/wiki/

Digital_Light_Processing

CS 89/189: Computational Photography, Fall 2015 31 After a slide by Matthias Zwicker

slide-32
SLIDE 32

3 sensors + beam splitter

High-end 3-CCD video cameras Use separation prisms

  • prisms that split wavelengths

Pros

  • 3 real values per pixel
  • Little photon loss

Cons

  • costly (needs 3 sensors)
  • space

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

slide-33
SLIDE 33

3 sensors + beam splitter

Technicolor

  • 3 negatives exposed at once
  • via beam splitter and filters
  • large, heavy cameras;

cumbersome printing process

CS 89/189: Computational Photography, Fall 2015 33

Wizard of Oz (1939)

After a slide by Steve Marschner

slide-34
SLIDE 34

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

  • single sensor
  • well mastered technology, high resolution

Cons

  • needs interpolation, color jaggies
  • requires antialiasing filter (reduces sharpness)
  • loss of light

Spatial multiplexing

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

slide-35
SLIDE 35

Spatial multiplexing

Bayer filter

  • http://en.wikipedia.org/wiki/Bayer_filter
  • Most common in digital cameras

2x2 pattern

  • 2 green, 1 red, 1 blue

Other mosaics exist, but not as
 widespread

CS 89/189: Computational Photography, Fall 2015 35

slide-36
SLIDE 36

Color displays

Spatial multiplexing

CS 89/189: Computational Photography, Fall 2015 36 http://en.wikipedia.org/wiki/RGB_color_model

slide-37
SLIDE 37

Combination: pixel shift

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

  • usually selectable (not shifted for lower-

res, shifted to get HD)

  • Often horizontal only

After a slide by Frédo Durand

slide-38
SLIDE 38

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

slide-39
SLIDE 39

Depth multiplexing (Foveon X3 sensor)

CS 89/189: Computational Photography, Fall 2015 39

Leverage difference in absorption per wavelength Pros

  • 3 real numbers per pixel
  • Less light loss

Cons

  • Requires more color processing (3 numbers must be

multiplied by matrix to get RGB)

  • Tends to be noisier (because color processing and

because shallow blue layer)

  • Lower resolution these days

After a slide by Frédo Durand

slide-40
SLIDE 40

Depth multiplexing

Good old color film (tripack)

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

slide-41
SLIDE 41

Interferences (Lippmann process)

Metal mirror to create interferences

  • ancestor of holography
  • similar to colors in thin oil film

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

slide-42
SLIDE 42

Interferences (Lippmann process)

Metal mirror to create interferences

  • ancestor of holography
  • similar to colors in thin oil film

Pros

  • Full spectrum!!!!!
  • Gets you the Nobel if you invent it ;-)

Cons

  • Needs high-resolution sensor/film
  • limited field of view for display

CS 89/189: Computational Photography, Fall 2015 42 'Saint-Maxime'', 1891-1899 
 Photographer: Gabriel Lippmann After a slide by Frédo Durand

slide-43
SLIDE 43

Recap & Questions?

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

slide-44
SLIDE 44

Bayer mosaic

slide-45
SLIDE 45

CS 89/189: Computational Photography, Fall 2015

Sensor

45 http://www.currentprotocols.com/WileyCDA/CPUnit/refId-ns0204.html After a slide by Frédo Durand

slide-46
SLIDE 46

CS 89/189: Computational Photography, Fall 2015

Microscope view of a CCD

46

By kevincollins123

http://www.flickr.com/photos/kevincollins123/4584180753/ After a slide by Frédo Durand

slide-47
SLIDE 47

Bayer RGB mosaic

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

slide-48
SLIDE 48

Bayer RGB mosaic

Why more green?

  • We have 3 channels and square

lattices don’t like odd numbers

  • It’s the spectrum “in the middle”
  • More important to human

perception of luminance

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

slide-49
SLIDE 49

RAW files

Straight measurement from sensor

  • right after A/D conversion

Each photosite has only one value

  • Filtered by R, G or B

Usually 12-14 bits per pixel Linear encoding

  • No gamma!

Can be read and converted using dcraw

  • ./dcrawx86 -v -d pics/DSC_8274.nef

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

slide-50
SLIDE 50

A RAW file from a Nikon D70

After a slide by Frédo Durand

slide-51
SLIDE 51

After a slide by Steve Marschner

slide-52
SLIDE 52

RAW Bayer data

After a slide by Steve Marschner After a slide by Steve Marschner

slide-53
SLIDE 53

Demosaicing

slide-54
SLIDE 54

Demosaicing

Interpolate missing values

  • 2/3 of the full-resolution data will be made up!

CS 89/189: Computational Photography, Fall 2015 54

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

After a slide by Frédo Durand

slide-55
SLIDE 55

Half-resolution demosaicing

Simplest solution: treat each block of 2x2 as a pixel

  • Problem 1: resolution loss (megapixels so important for marketing!)
  • Problem 2: produces subpixel shifts in color planes!

CS 89/189: Computational Photography, Fall 2015 55 After a slide by F. Durand & S. Marschner

slide-56
SLIDE 56

RAW bayer data

After a slide by Steve Marschner

slide-57
SLIDE 57

2x2 bayer block

After a slide by Steve Marschner

slide-58
SLIDE 58

Centered half-resolution

Average pixels in groups that all have the same “center

  • f gravity”
  • avoids major color fringing

CS 89/189: Computational Photography, Fall 2015 58

? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

After a slide by Steve Marschner

slide-59
SLIDE 59

Centered half-resolution

Average pixels in groups that all have the same “center

  • f gravity”
  • avoids major color fringing

CS 89/189: Computational Photography, Fall 2015 59

? ? ? ? ? O ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? O ? ? ? ? ? ? ? ? ? ?

After a slide by Steve Marschner

slide-60
SLIDE 60

RAW bayer data

After a slide by Steve Marschner

slide-61
SLIDE 61

2x2 bayer block

After a slide by Steve Marschner

slide-62
SLIDE 62

centered

After a slide by Steve Marschner

slide-63
SLIDE 63

Linear interpolation

Average the 4 or 2 nearest neighbors (linear/tent kernel)

  • e.g. newgreen = 0.25 * (up+left+right+down)

CS 89/189: Computational Photography, Fall 2015 63

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

After a slide by Frédo Durand

slide-64
SLIDE 64

RAW Bayer data

After a slide by Steve Marschner

slide-65
SLIDE 65

2x2 Bayer block

After a slide by Steve Marschner

slide-66
SLIDE 66

centered

After a slide by Steve Marschner

slide-67
SLIDE 67

linear

After a slide by Steve Marschner

slide-68
SLIDE 68

Better

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

slide-69
SLIDE 69

Results of simple linear

After a slide by Frédo Durand

slide-70
SLIDE 70

Results - not perfect

After a slide by Frédo Durand

slide-71
SLIDE 71

Questions?

After a slide by Frédo Durand

slide-72
SLIDE 72

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

The problem

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

slide-73
SLIDE 73

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

The problem

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

slide-74
SLIDE 74

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

The problem

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

slide-75
SLIDE 75

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

The problem

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

slide-76
SLIDE 76

Yep, that’s what we saw

After a slide by Frédo Durand

slide-77
SLIDE 77

Green channel

After a slide by Frédo Durand

slide-78
SLIDE 78

Edge-based Demosaicing

slide-79
SLIDE 79

Idea

Take into account structure in image

  • Here, 1D edges

Interpolate along preferred direction

  • In our case, only use 2

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

slide-80
SLIDE 80

How do we decide?

Look at the similarity of recorded neighbors

  • Compare |up-down| to |right-left|
  • Be smart
  • See Assignment 3

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

slide-81
SLIDE 81

Green channel — naïve

After a slide by Frédo Durand

slide-82
SLIDE 82

Green channel — edge-based

After a slide by Frédo Durand

slide-83
SLIDE 83

Challenge with

  • ther channels
slide-84
SLIDE 84

Problem

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

slide-85
SLIDE 85

? ? ? ?

Example (black-on-white corner)

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

slide-86
SLIDE 86

Example (black-on-white corner)

Even if we could do a decent job for each channel, the channels don’t line up

  • because they are not recorded at the same location

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

slide-87
SLIDE 87

Example (black-on-white corner)

Even if we could do a decent job for each channel, the channels don’t line up

  • because they are not recorded at the same location

CS 89/189: Computational Photography, Fall 2015 87

+ +

After a slide by Frédo Durand

slide-88
SLIDE 88

Example (black-on-white corner)

Even if we could do a decent job for each channel, the channels don’t line up

  • because they are not recorded at the same location

CS 89/189: Computational Photography, Fall 2015 88

Bad color fringes!

After a slide by Frédo Durand

slide-89
SLIDE 89

Recall color artifacts

After a slide by Frédo Durand

slide-90
SLIDE 90

Green-based Demosaicing

slide-91
SLIDE 91

Green-based demosaicing

Green is a better color channel

  • Twice as many pixels
  • Often better SNR
  • We know how to do edge-based green interpolation

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

slide-92
SLIDE 92

Interpolate difference to green

Interpolate green

  • using e.g. edge-based

For recorded red pixels

  • compute R-G

At empty pixels

  • Interpolate R-G naïvely
  • Add G

Same for blue

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

slide-93
SLIDE 93

Black-on-white corner

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

slide-94
SLIDE 94

Measurements

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

slide-95
SLIDE 95

Edge-based green

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

slide-96
SLIDE 96

Red-Green difference

CS 89/189: Computational Photography, Fall 2015 96

Zero everywhere!

After a slide by Frédo Durand

slide-97
SLIDE 97

Red-Green difference

CS 89/189: Computational Photography, Fall 2015 97

Zero everywhere!

  • Easy!

After a slide by Frédo Durand

slide-98
SLIDE 98

Add back green

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

slide-99
SLIDE 99

Repeat for blue

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

slide-100
SLIDE 100

Fully naïve

After a slide by Frédo Durand

slide-101
SLIDE 101

Edge-based green, naïve red blue

After a slide by Frédo Durand

slide-102
SLIDE 102

Green-based blue and red

After a slide by Frédo Durand

slide-103
SLIDE 103

Still not 100% perfect

After a slide by Frédo Durand

slide-104
SLIDE 104

RAW bayer data

After a slide by Steve Marschner

slide-105
SLIDE 105

2x2 bayer block

After a slide by Steve Marschner

slide-106
SLIDE 106

centered

After a slide by Steve Marschner

slide-107
SLIDE 107

linear

After a slide by Steve Marschner

slide-108
SLIDE 108

edge-based

After a slide by Steve Marschner

slide-109
SLIDE 109

dcraw

After a slide by Steve Marschner

slide-110
SLIDE 110

Questions?

CS 89/189: Computational Photography, Fall 2015 110

slide-111
SLIDE 111

Alternative

Interpolate ratio

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

slide-112
SLIDE 112

Edge cases

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

slide-113
SLIDE 113

Denoising & Demosaicking

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

slide-114
SLIDE 114

Demosaicing inversion

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

slide-115
SLIDE 115

Links

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

slide-116
SLIDE 116

Color correction & calibration

slide-117
SLIDE 117

Measured pixel values are not CIE RGB values! Remap to appropriate colorspace using transformation derived from response curves

  • f color filters (sensor

specific)

CS 89/189: Computational Photography, Fall 2015 117

Sensor architecture

slide-118
SLIDE 118

Color sensing

Sensor is like eye

  • gives you projection onto a 3D (or >3D) space
  • but it is the wrong space!

Problems with measured data

  • we have RGB, but not the right RGB
  • projection onto sensitivities, not coefficients for primaries (always)
  • projection onto wrong space
  • results depend strongly on illuminant (help!)

CS 89/189: Computational Photography, Fall 2015 118 After a slide by Steve Marschner

slide-119
SLIDE 119

Camera pixel pipeline

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

slide-120
SLIDE 120

Sensor color properties

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

slide-121
SLIDE 121

Camera color problem

CS 89/189: Computational Photography, Fall 2015 121

span of camera’s spectral response functions camera metamer

  • f s

spectrum s span of eye’s spectral response functions s’ visual metamer

  • f s’

Given camera response, guess corresponding visual response This guess has to involve assumptions about which reflectance spectra are more likely Mathematical approach:

  • assume spectra in fixed subspace

Or, more often, just derive a transformation empirically

After a slide by Steve Marschner

slide-122
SLIDE 122

Assume spectrum s is a combination of three spectra Work out what combination it is

  • same math as additive color matching

Camera color rendering via subspace

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

slide-123
SLIDE 123

  S M L   =   rS rM rL    

| | |

s1 s2 s3

| | |

   

Assume spectrum s is a combination of three spectra Work out what combination it is

  • same math as additive color matching

Camera color rendering via subspace

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  

slide-124
SLIDE 124

Empirical color transformation

Baseline method: use Macbeth Color Checker

  • a set of square patches of known color


(these days you buy the MCC from X-Rite)

Procedure

  • 1. Photograph the color checker under uniform illumination
  • 2. Measure the camera-RGB values of the 24 squares
  • 3. Look up the XYZ colors of the 24 squares
  • 4. Use linear least squares to find a 3x3 matrix that

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

slide-125
SLIDE 125

Considering the illuminant

Problem with previous slide

  • the camera-RGB colors depend on the illuminant
  • the matrix M only works for the illuminant that was used to calibrate!

Solutions?

  • calibrate separately for every illuminant?
  • correct for illuminant first, then apply matrix!

von Kries hypothesis: eye accounts for illuminant by simply scaling the three cone signals separately

  • leads to “von Kries transform”: multiply by a diagonal matrix

CS 89/189: Computational Photography, Fall 2015 125

slide-126
SLIDE 126

Putting it together: color processing

Calibrate your color matrix using a carefully white-balanced image

  • when solving for M, constrain to ensure rows sum to 1


(then M will leave neutral colors exactly alone)

For each photograph:

  • 1. determine illuminant
  • 2. apply von Kries
  • 3. apply color matrix
  • 4. apply any desired nonlinearity
  • 5. display the image!

CS 89/189: Computational Photography, Fall 2015 126

slide-127
SLIDE 127

raw sensor color

slide-128
SLIDE 128

white balanced raw sensor color

slide-129
SLIDE 129

white balanced and matrixed to sRGB

slide-130
SLIDE 130

Slide credits

Frédo Durand Steve Marschner Matthias Zwicker Marc Levoy

CS 89/189: Computational Photography, Fall 2015 130