Image Processing Basics
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 Image Processing Basics Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu Domain, range Domain vs. range 2D plane: domain of images color
Image Processing Basics
Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu
CS 89.15/189.5, Fall 2015
2D plane: domain of images color value: range (R3 for us)
im(x, y, 0), im(x, y, 1), im(x, y, 2), respectively
CS 89/189: Computational Photography, Fall 2015 3 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015
4
Point operations: range only Assignment 2
After a slide by Frédo Durand
image(x,y)
CS 89/189: Computational Photography, Fall 2015
5
Point operations: range only Assignment 2
After a slide by Frédo Durand
Domain
Assignment 6
image(x,y)
CS 89/189: Computational Photography, Fall 2015
6
Point operations: range only Assignment 2
After a slide by Frédo Durand
Domain
Assignment 6 Neighborhood operations: domain and range Assignments 3, 4, 5
image(x,y)
Light from sources is reflected by objects and reaches the eye The amount of light from the source gets multiplied by the object reflectance
CS 89/189: Computational Photography, Fall 2015 8 After a slide by Frédo Durand
Our eyes have an uncanny ability to discount the illumination
CS 89/189: Computational Photography, Fall 2015 9 After a slide by Frédo Durand
A & B have exactly the same tone
CS 89/189: Computational Photography, Fall 2015 10 After a slide by Frédo Durand
A & B have exactly the same tone
CS 89/189: Computational Photography, Fall 2015 11 After a slide by Frédo Durand
Light adaptation
brightness
Chromatic adaptation
e.g. Daylight is white but tungsten is yellowish
CS 89/189: Computational Photography, Fall 2015 12 After a slide by Frédo Durand
Contrast between 1 & 2 is the same as between 100 & 200 Useful to discount the multiplicative effect of light
CS 89/189: Computational Photography, Fall 2015 13
0.1 to 0.2 0.4 to 0.8
After a slide by Frédo Durand
On cameras, exposure (shutter speed, aperture, ISO) has a multiplicative effect on the values recorded by the sensor. Changes the “brightness”, not contrast
CS 89/189: Computational Photography, Fall 2015 14 http://photographystepbystep.com/exposure-2/auto-bracketing/ After a slide by Frédo Durand
Different illuminants have different color temperature Our eyes adapt: chromatic adaptation
CS 89/189: Computational Photography, Fall 2015 16
www.shortcourses.com/guide/guide2-27.html
After a slide by Frédo Durand
When watching a picture on screen or print, we adapt to the illuminant of the room, not that of the scene in the picture The eye cares more about objects’ intrinsic color, not the color of the light leaving the objects We need to discount the color of the light source
CS 89/189: Computational Photography, Fall 2015 17
Same object, different illuminants
After a slide by Frédo Durand
Different types of film for fluorescent, tungsten, daylight Need to change film! Electronic & Digital imaging are more flexible
CS 89/189: Computational Photography, Fall 2015 18 After a slide by Frédo Durand
Multiply each channel by a gain factor
CS 89/189: Computational Photography, Fall 2015 19 http://www.cambridgeincolour.com/tutorials/white-balance.htm After a slide by Frédo Durand
Multiply each channel by a gain factor Note that the light source could have a more complex effect
CS 89/189: Computational Photography, Fall 2015 20 http://www.cambridgeincolour.com/tutorials/white-balance.htm After a slide by Frédo Durand
How do we find the scaling factors for r, g, and b?
CS 89/189: Computational Photography, Fall 2015 21 After a slide by Frédo Durand
Grey card: Take a picture of a neutral object (white or gray) Deduce the weight of each channel If the object is recoded as rw, gw, bw use weights k/rw, k/gw, k/bw where k controls the exposure
CS 89/189: Computational Photography, Fall 2015 22 After a slide by Frédo Durand
Most photo editing software lets you click
balance
daylight, tungsten
CS 89/189: Computational Photography, Fall 2015 23 After a slide by Frédo Durand
Provide excellent white references!
CS 89/189: Computational Photography, Fall 2015 24
write(im/im(300, 214))
After a slide by Frédo Durand
We need to “guess” which pixels correspond to white
CS 89/189: Computational Photography, Fall 2015 25 After a slide by Frédo Durand
Assume average color in the image is grey Use weights proportional to Usually assumes 18% grey to set exposure
CS 89/189: Computational Photography, Fall 2015 26 After a slide by Frédo Durand
Highlights usually have the color of the light source
White balance by using the brightest pixels
CS 89/189: Computational Photography, Fall 2015 27 After a slide by Frédo Durand
Recent work on color constancy
space-illuminationinvariant-image-processing
photometric-invariants
Still an open problem!
CS 89/189: Computational Photography, Fall 2015 28 After a slide by Frédo Durand
CS 89/189: Computational Photography, Fall 2015
29
from xkcd
After a slide by Frédo Durand
Discounting the illumination is useful Ratios matter Optical illusions are not optical but fun
CS 89/189: Computational Photography, Fall 2015 30 After a slide by Frédo Durand
Images are usually gamma encoded Instead of storing the light intensity x, they store x𝛿 to get more precision in dark areas for 8-bit encoding
CS 89/189: Computational Photography, Fall 2015 32 After a slide by Frédo Durand
gamma compression curve
real value stored value
Images are usually gamma encoded Instead of storing the light intensity x, they store x𝛿 to get more precision in dark areas for 8-bit encoding
CS 89/189: Computational Photography, Fall 2015 33
6 bit encoding for emphasis:
After a slide by Frédo Durand
http://web.mit.edu/lilis/www/gammavis.html
CS 89/189: Computational Photography, Fall 2015 34 After a slide by Frédo Durand
Images are usually gamma encoded Instead of storing the light intensity x, they store x𝛿 Half of image processing algorithms work better in linear space
Half work better in gamma space
CS 89/189: Computational Photography, Fall 2015 35 After a slide by Frédo Durand
http://www.mit.edu/~kimo/blog/linear.html
CS 89/189: Computational Photography, Fall 2015 36 After a slide by Frédo Durand
Images are usually gamma-encoded gamma ~2.2 provides better quantization sometimes good for algorithms sometimes bad
CS 89/189: Computational Photography, Fall 2015 37 After a slide by Frédo Durand
Histogram:
this value?
Cumulative histogram:
smaller than x?
Normalized: divide value of each bin by total number of pixels
CS 89/189: Computational Photography, Fall 2015 39
(wikipedia)
After a slide by Frédo Durand
pixel value #pixels
Allows you to tell if you use the dynamic range entirely
CS 89/189: Computational Photography, Fall 2015 40 After a slide by Frédo Durand
Bad: bright values under-used (underexposure) Bad: bright values saturate (overexposure)
http://www.luminous-landscape.com/tutorials/understanding-series/understanding-histograms.shtml
Given an image with a certain histogram, monotonic remapping to get a flat histogram
CS 89/189: Computational Photography, Fall 2015 43 pixel value #pixels pixel value #pixels
new pixel value http://en.wikipedia.org/wiki/Histogram_equalization
Ideal flat histogram: y% of pixels have a value less than y%
Flip it: a pixel with value larger than y% of all pixels should have value y% For an old value x%, we know the number of pixels that have value < x%: cumulative histogram (also called CDF) Therefore, we want x to be mapped to its cumulative histogram value.
CS 89/189: Computational Photography, Fall 2015 44
Histogram matching
that the new histogram matches the desired histogram
Histogram equalization
CS 89/189: Computational Photography, Fall 2015 45
target
CS 89/189: Computational Photography, Fall 2015 46
% of pixels intensity bin
255 100 G1
Histogram matching is done by adjusting the cumulative distribution function (cdf)
input
Histogram matching is done by adjusting the cumulative distribution function (cdf)
histogram of target
CS 89/189: Computational Photography, Fall 2015 47
% of pixels intensity bin
255 100 G1 target G2 target input
Histogram matching is done by adjusting the cumulative distribution function (cdf)
histogram of target (linear)
CS 89/189: Computational Photography, Fall 2015 48
% of pixels intensity bin
255 100 G1 target G2 input
Cumulative distribution function (CDF)
CS 89/189: Computational Photography, Fall 2015
49
Input Equalized
Doubt everything Debug pieces in isolation
Display/print everything
Create simple inputs
the result
to intermediate stages
different failure modes
Change one thing at a time
command has the effect you want, modify it to break it
CS 89/189: Computational Photography, Fall 2015 51
Frédo Durand
CS 89/189: Computational Photography, Fall 2015 52