histograms and color balancing computational photography derek hoiem, university of illinois...

42
Histograms and Color Balancing Computational Photography Derek Hoiem, University 09/13/11 “Empire of Light”, Magritte

Upload: kellie-francis

Post on 18-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Histograms and Color Balancing

Computational PhotographyDerek Hoiem, University of Illinois

09/13/11

“Empire of Light”, Magritte

Page 2: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Administrative stuff

• New office hours: Monday 10-11, 3-4

• Project 1 in, more discussion next Tues– Vote for class favorite overall project and result;

can vote for multiple projects/results

Page 3: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Review of last class

Possible factors: albedo, shadows, texture, specularities, curvature, lighting direction

1.

Page 4: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Review of last class

12

3

4

5

6

1. Why is (2) brighter than (1)? Each points to the asphault. 2. Why is (4) darker than (3)? 4 points to the marking. 3. Why is (5) brighter than (3)? Each points to the side of the wooden block. 4. Why isn’t (6) black, given that there is no direct path from it to the sun?

Page 5: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Today’s class• How can we represent color?• How do we adjust the intensity of an image to

improve contrast, aesthetics?

Page 6: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

© Stephen E. Palmer, 2002

.

400 450 500 550 600 650

RE

LATI

VE

AB

SO

RB

AN

CE

(%)

WAVELENGTH (nm.)

100

50

440

S

530 560 nm.

M L

Three kinds of cones:

Physiology of Color Vision

• Why are M and L cones so close?• Why are there 3?

Page 7: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color spaces: RGB

0,1,0

0,0,1

1,0,0

Image from: http://en.wikipedia.org/wiki/File:RGB_color_solid_cube.png

Some drawbacks• Strongly correlated channels• Non-perceptual

Default color space

R(G=0,B=0)

G(R=0,B=0)

B(R=0,G=0)

Page 8: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Trichromacy and CIE-XYZ

Perceptual equivalents with RGB Perceptual equivalents with CIE-XYZ

Page 9: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color Space: CIE-XYZ

RGB portion is in triangle

Page 10: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Perceptual uniformity

Page 11: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color spaces: CIE L*a*b*“Perceptually uniform” color space

L(a=0,b=0)

a(L=65,b=0)

b(L=65,a=0)

Luminance = brightnessChrominance = color

Page 12: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

If you had to choose, would you rather go without luminance or chrominance?

Page 13: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

If you had to choose, would you rather go without luminance or chrominance?

Page 14: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Most information in intensity

Only color shown – constant intensity

Page 15: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Most information in intensity

Only intensity shown – constant color

Page 16: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Most information in intensity

Original image

Page 17: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color spaces: HSV

Intuitive color space

H(S=1,V=1)

S(H=1,V=1)

V(H=1,S=0)

Page 18: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color spaces: YCbCr

Y(Cb=0.5,Cr=0.5)

Cb(Y=0.5,Cr=0.5)

Cr(Y=0.5,Cb=05)

Y=0 Y=0.5

Y=1Cb

Cr

Fast to compute, good for compression, used by TV

Page 19: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color balancing

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

Page 20: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color balancing

Photos: http://www.kenrockwell.com/tech/whitebalance.htm

Page 21: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Important ideas

• Typical images are gray on average; this can be used to detect distortions

• Larger differences are more visible, so using the full intensity range improves visibility

• It’s often easier to work in a non-RGB color space

Page 22: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Color balancing via linear adjustment• Simple idea: multiply R, G, and B values by

separate constants=

• How to choose the constants?– “Gray world” assumption: average value should be

gray– White balancing: choose a reference as the white or

gray color– Better to balance in camera’s RGB (linear) than

display RGB (non-linear)

Page 23: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Tone Mapping• Typical problem: compress values from a high

range to a smaller range– E.g., camera captures 12-bit linear intensity and

needs to compress to 8 bits

Page 24: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Example: Linear display of HDR

Scaled for brightest pixels Scaled for darkest pixels

Page 25: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Global operator (Reinhart et al.)• Simple solution: map to a non-linear range of

values

world

worlddisplay L

LL

1

Page 26: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Darkest 0.1% scaledto display device

Reinhart Operator

Page 27: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Simple Point Processing

Some figs from A. Efros’ slides

Page 28: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Negative

Page 29: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Log

Page 30: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Power-law transformations

𝑠=𝑟 𝛾

Page 31: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Image Enhancement

Page 32: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Contrast Stretching

Page 33: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Histogram equalization• Basic idea: reassign values so that the number

of pixels with each value is more evenly distributed

• Histogram: a count of how many pixels have each value

• Cumulative histogram: count of number of pixels less than or equal to each value

Page 34: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Image Histograms

Cumulative Histograms

Page 35: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Histogram Equalization

Page 36: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Algorithm for global histogram equalization

Goal: Given image with pixel valuesspecify function that remaps pixel values, so that the new values are more broadly distributed

1. Compute cumulative histogram: ,

2. – Blends between original image and image with

uniform histogram

Page 37: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Locally weighted histograms• Compute cumulative histograms in non-

overlapping MxM grid• For each pixel, interpolate between the

histograms from the four nearest grid cells

Figure from Szeliski book (Fig. 3.9)Pixel (black) is mapped based on interpolated value from its cell and nearest horizontal, vertical, diagonal neighbors

Page 38: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Other issues• Dealing with color images

– Often better to split into luminance and chrominance to avoid unwanted color shift

• Manipulating particular regions– Can use mask to select particular areas for

manipulation

• Useful Matlab functions– rgb2hsv, hsv2rgb, hist, cumsum,

Page 39: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Project 2: due Sept 26• Part I: Alignment• Part II: Enhance contrast and color

Page 40: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Examples with Matlab

Page 41: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Things to remember

• Familiarize yourself with the basic color spaces: RGB, HSV, Lab

• Simple auto contrast/color adjustments: gray world assumption, histogram equalization

• When improving contrast in a color image, often best to operate on luminance channel

Page 42: Histograms and Color Balancing Computational Photography Derek Hoiem, University of Illinois 09/13/11 “Empire of Light”, Magritte

Next class: finding seams