tonemapping and bilateral filtering - computer...

104
Tonemapping and bilateral filtering 15-463, 15-663, 15-862 Computational Photography Fall 2018, Lecture 6 http://graphics.cs.cmu.edu/courses/15-463

Upload: others

Post on 18-Oct-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Tonemapping and bilateral filtering

15-463, 15-663, 15-862Computational Photography

Fall 2018, Lecture 6http://graphics.cs.cmu.edu/courses/15-463

Page 2: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Course announcements

• Homework 2 is out.- Due September 28th. - Requires camera and tripod.- Still five cameras left if anybody needs one.- Start early! Large programming component and generous bonus.

• Any issues with Homework 1?- How did you find homework 1 in general?- Which part of homework 1 did you enjoy the most?

Page 3: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Overview of today’s lecture

• Leftover from lecture 5: optimal weights for HDR merging.

• Color calibration and homography estimation.

• Tonemapping.

• Edge-aware filtering and bilateral filtering.

• Back to tonemapping.

• Some notes about HDR and tonemapping.

Page 4: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Slide credits

Many of these slides were inspired or adapted from:

• James Hays (Georgia Tech).• Fredo Durand (MIT).• Gordon Wetzstein (Stanford).• Sylvain Paris (MIT).• Sam Hasinoff (Google).

Page 5: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Color calibration and homography estimation

Page 6: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Many different spectral sensitivity functions

Each camera has its more or less unique, and most of the time secret, SSF.• Makes it very difficult to correctly reproduce the color of sensor measurements.

Images of the same scene captured using 3 different cameras with identical sRGB settings.

Page 7: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Color calibrationApply linear scaling and translation to RGB vectors in the image:

transformed RGB vector original RGB vector

𝑐′ = 𝑀 ∙ 𝑐 + 𝑏

What are the dimensions of each quantity in this equation?

Page 8: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Color calibrationApply linear scaling and translation to RGB vectors in the image:

transformed RGB vector original RGB vector

𝑐′ = 𝑀 ∙ 𝑐 + 𝑏

What are the dimensions of each quantity in this equation?

How do we decide what transformed vectors to map to?

Page 9: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Using (again) a color checker

Calibration chart can be used for:

1. color calibration

2. radiometric calibration (i.e., response curve) using the bottom row

Color patches manufactured to have pre-calibrated XYZ coordinates.

Page 10: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Using (again) a color checker

Calibration chart can be used for:

1. color calibration

2. radiometric calibration (i.e., response curve) using the bottom row

Color patches manufactured to have pre-calibrated XYZ coordinates.

Can we use any color chart image for color calibration?

Page 11: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Using (again) a color checker

Calibration chart can be used for:

1. color calibration

2. radiometric calibration (i.e., response curve) using the bottom row

Color patches manufactured to have pre-calibrated XYZ coordinates.

Can we use any color chart image for color calibration?

- It needs to be a linear image!

- Do radiometric calibration first.

Page 12: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Color calibrationApply linear scaling and translation to RGB vectors in the image:

transformed RGB vector original RGB vector

𝑐′ = 𝑀 ∙ 𝑐 + 𝑏

What are the dimensions of each quantity in this equation?

How do we decide what transformed vectors to map to?

How do we solve for matrix M and vector b?

Page 13: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Color calibrationApply linear scaling and translation to RGB vectors in the image:

𝑐′

1=

𝑀 𝑏0 1

𝑐1

Page 14: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Color calibrationApply linear scaling and translation to RGB vectors in the image:

𝑐′

1=

𝑀 𝑏0 1

𝑐1

𝐶′ 𝐻 𝐶

Page 15: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Color calibrationApply a homography to homogeneous RGB vectors in the image:

homogeneous transformed RGB vector

𝐶′ = 𝐻 ∙ 𝐶

homogeneous original RGB vector

How do we solve for a homography transformation?

Page 16: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Determining the homography matrix

Write out linear equation for each color vector correspondence:

𝑟′

𝑔′

𝑏′

1

= 𝑎

ℎ1 ℎ2 ℎ3ℎ5 ℎ6 ℎ7ℎ9 ℎ10 ℎ11

ℎ4ℎ8ℎ12

ℎ13 ℎ14 ℎ15 ℎ13

𝑟𝑔𝑏1

𝐶′ = 𝐻 ∙ 𝐶 or

Page 17: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Determining the homography matrix

Write out linear equation for each color vector correspondence:

𝑟′

𝑔′

𝑏′

1

= 𝑎

ℎ1 ℎ2 ℎ3ℎ5 ℎ6 ℎ7ℎ9 ℎ10 ℎ11

ℎ4ℎ8ℎ12

ℎ13 ℎ14 ℎ15 ℎ13

𝑟𝑔𝑏1

𝐶′ = 𝐻 ∙ 𝐶 or

𝑟′ = 𝑎 ℎ1𝑟 + ℎ2𝑔 + ℎ3𝑏 + ℎ4𝑔′ = 𝑎 ℎ5𝑟 + ℎ6𝑔 + ℎ7𝑏 + ℎ8𝑏′ = 𝑎 ℎ9𝑟 + ℎ10𝑔 + ℎ11𝑏 + ℎ121 = 𝑎 ℎ13𝑟 + ℎ14𝑔 + ℎ15𝑏 + ℎ16

Expand matrix multiplication:

Page 18: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Determining the homography matrix

𝑟′ ℎ13𝑟 + ℎ14𝑔 + ℎ15𝑏 + ℎ16 = ℎ1𝑟 + ℎ2𝑔 + ℎ3𝑏 + ℎ4𝑔′ ℎ13𝑟 + ℎ14𝑔 + ℎ15𝑏 + ℎ16 = ℎ5𝑟 + ℎ6𝑔 + ℎ7𝑏 + ℎ8𝑏′ ℎ13𝑟 + ℎ14𝑔 + ℎ15𝑏 + ℎ16 = ℎ9𝑟 + ℎ10𝑔 + ℎ11𝑏 + ℎ12

Divide out unknown scale factor:

Page 19: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Determining the homography matrix

𝑟′ ℎ13𝑟 + ℎ14𝑔 + ℎ15𝑏 + ℎ16 = ℎ1𝑟 + ℎ2𝑔 + ℎ3𝑏 + ℎ4𝑔′ ℎ13𝑟 + ℎ14𝑔 + ℎ15𝑏 + ℎ16 = ℎ5𝑟 + ℎ6𝑔 + ℎ7𝑏 + ℎ8𝑏′ ℎ13𝑟 + ℎ14𝑔 + ℎ15𝑏 + ℎ16 = ℎ9𝑟 + ℎ10𝑔 + ℎ11𝑏 + ℎ12

Rearrange as a linear constraint on entries of H:

Divide out unknown scale factor:

𝑟′𝑟ℎ13 + 𝑟′𝑔ℎ14 + 𝑟′𝑏ℎ15 + 𝑟′ℎ16 − 𝑟ℎ1 − 𝑔ℎ2 − 𝑏ℎ3 − ℎ4 = 0𝑔′𝑟ℎ13 + 𝑔′𝑔ℎ14 + 𝑔′𝑏ℎ15 + 𝑔′ℎ16 − 𝑟ℎ5 − 𝑔ℎ6 − 𝑏ℎ7 − ℎ8 = 0𝑏′𝑟ℎ13 + 𝑏′𝑔ℎ14 + 𝑏′𝑏ℎ15 + 𝑏′ℎ16 − 𝑟ℎ9 − 𝑔ℎ10 − 𝑏ℎ11 − ℎ12 = 0

Page 20: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Determining the homography matrixRe-write in matrix form:

What are the dimensions of each

variable in this system?

How many equations from one color vector

correspondence?

How many color vector correspondences do we

need?

Page 21: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Determining the homography matrixRe-write in matrix form:

Stack together constraints from additional color vector correspondences row-wise:

Homogeneous linear least squares system.• How do we solve such systems?

Page 22: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Determining the homography matrixRe-write in matrix form:

Stack together constraints from additional color vector correspondences row-wise:

Homogeneous linear least squares system.• How do we solve such systems? → Use singular value decomposition (SVD)

Page 23: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

General form of total least squares

(matrix form)

(Warning: change of notation. x is a vector of parameters!)

constraint

minimize

subject to

minimize

Solution is the eigenvector corresponding to smallest eigenvalue of

(Rayleigh quotient)

Solution is the column of Vcorresponding to smallest singular value(equivalent)

Page 24: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

An example

original color-corrected

Page 25: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Quick note

If you cannot do calibration, take a look at the image’s EXIF data (if available).

Often contains information about tone reproduction curve and color space.

Page 26: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Tonemapping

Page 27: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

How do we display our HDR images?

10-6 106

adaptation range of our eyes

common real-world scenes

10-6 106image

10-6 106

HDR image

10-6 106display

Page 28: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Linear scalingScale image so that maximum value equals 1

Can you think of something better?

Page 29: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Photographic tonemapping

Apply the same non-linear scaling to all pixels in the image so that:• Bring everything within range → asymptote to 1• Leave dark areas alone → slope = 1 near 0

(exact formula more complicated)

HDR

HDR

displayI

II

+=

1

• Photographic because designed to approximate film zone system.• Perceptually motivated, as it approximates our eye’s response curve.

Page 30: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

What is the zone system?• Technique formulated by Ansel Adams for film development.• Still used with digital photography.

Page 31: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Examples

Page 32: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Examples

photographic tonemapping

linear scaling (map 10% to 1)

Page 33: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Compare with LDR images

Page 34: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Dealing with color

If we tonemap all channels the same, colors are washed out

Can you think of a way to deal with this?

Page 35: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Intensity-only tonemapping

tonemapintensity

How would you implement this?

leave color the same

Page 36: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison

Color now OK, but some details are washed out due to loss of contrast

Can you think of a way to deal with this?

Page 37: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Low-frequency intensity-only tonemapping

tonemap low-frequency intensity component

How would you implement this?

leave color the same

leave high-frequency intensity component

the same

Page 38: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison

We got nice color and contrast, but now we’ve run into the halo plague

Can you think of a way to deal with this?

Page 39: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Edge-aware filtering and bilateral filtering

Page 40: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Motivational example

Let’s say I want to reduce the amount of detail in this picture. What can I do?

original

Page 41: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Motivational example

What is the problem here?

original Gaussian filtering

Page 42: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Motivational example

original Gaussian filtering

How to smooth out the details in the image without losing the important edges?

Page 43: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Motivational example

original Gaussian filtering bilateral filtering

Page 44: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

The problem with Gaussian filtering

input

Gaussian kernel

*

*

*

output

Why is the output so blurry?

Page 45: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

The problem with Gaussian filtering

input

Gaussian kernel

*

*

*

output

Blur kernel averages across edges

Page 46: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

The bilateral filtering solution

input

bilateral filter kernel

*

*

*

output

Do not blur if there is an edge! How does it do that?

Page 47: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering

Page 48: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering

Spatial weighting

1) it’s nearbyAssign a pixel a large weight if:

Page 49: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering

Intensity range weighting

2) it looks like meand

Spatial weighting

1) it’s nearbyAssign a pixel a large weight if:

Page 50: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering

Normalization factor Intensity range weighting

2) it looks like meand

Spatial weighting

1) it’s nearbyAssign a pixel a large weight if:

Page 51: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering vs Gaussian filtering

Which is which?

Page 52: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering vs Gaussian filtering

Gaussian filtering

Bilateral filtering

Page 53: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering vs Gaussian filtering

Gaussian filtering

Bilateral filteringSpatial weighting: favor nearby pixels

Page 54: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering vs Gaussian filtering

Gaussian filtering

Bilateral filteringSpatial weighting: favor nearby pixels

Intensity range weighting: favor similar pixels

Page 55: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering vs Gaussian filtering

Gaussian filtering

Bilateral filteringSpatial weighting: favor nearby pixels

Normalization factor

Intensity range weighting: favor similar pixels

Page 56: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering vs Gaussian filtering

Gaussian filtering

Bilateral filtering

Smooths everything nearby (even edges)Only depends on spatial distance

Smooths ‘close’ pixels in space and intensityDepends on spatial and intensity distance

Page 57: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Gaussian filtering visualization

Output Gaussian Filter Input

Page 58: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Bilateral filtering visualization

Output Bilateral Filter Input

Spatial range Intensity range

Page 59: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Exploring the bilateral filter parameter space

input

ss = 2

ss = 6

ss = 18

sr = 0.1 sr = 0.25sr =

(Gaussian blur)

Page 60: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Does the bilateral filter respect all edges?

input

bilateral filter kernel

*

*

*

output

Page 61: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Does the bilateral filter respect all edges?

input

bilateral filter kernel

*

*

output

Bilateral filter crosses (and blurs) thin edges.

Page 62: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Denoising

noisy input bilateral filtering median filtering

Page 63: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Contrast enhancement

input sharpening based on bilateral filtering

sharpening based on Gaussian filtering

How would you use Gaussian or bilateral filtering for sharpening?

Page 64: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Photo retouching

Page 65: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Photo retouching

original digital pore removal (aka bilateral filtering)

Page 66: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Before

Page 67: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

After

Page 68: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Close-up comparison

original digital pore removal (aka bilateral filtering)

Page 69: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Cartoonization

input cartoon rendition

Page 70: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Cartoonization

How would you create this effect?

Page 71: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Cartoonization

edges from bilaterally filtered image bilaterally filtered image

+ =

cartoon rendition

Note: image cartoonization and abstraction are very active research areas.

Page 72: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Is the bilateral filter:

Shift-invariant?

Linear?

Page 73: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Is the bilateral filter:

Shift-invariant?

Linear?

• No.

• No.

Does this have any bad implications?

Page 74: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

The bilateral grid

Data structure for fast edge-aware image processing.

Page 75: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Modern edge-aware filtering: local Laplacian pyramids

Page 76: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Modern edge-aware filtering: local Laplacian pyramids

input

texture decrease

texture increase

large texture increase

Page 77: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Tonemapping with edge-aware filtering

Page 78: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Tonemapping with edge-aware filtering

bilateral filterlocal Laplacian pyramids

Page 79: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Back to tonemapping

Page 80: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison

We got nice color and contrast, but now we’ve run into the halo plague

Can you think of a way to deal with this?

Page 81: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Tonemapping with bilateral filtering

Page 82: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison

We fixed the halos without losing contrast

Page 83: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 84: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Gradient-domain merging and tonemappingCompute gradients, scale and merge them, then integrate (solve Poisson problem).• More in lecture 7.

Page 85: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Gradient-domain merging and tonemapping

Page 86: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison (which one do you like better?)

photographic bilateral filtering gradient-domain

Page 87: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison (which one do you like better?)

photographic bilateral filtering gradient-domain

Page 88: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison (which one do you like better?)

bilateral filtering gradient-domainphotographic

Page 89: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Comparison (which one do you like better?)

bilateral filtering gradient-domainphotographic

There is no ground-truth: which one looks better is entirely subjective

Page 90: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Tonemapping for a single image

result from image processing pipeline

(basic tone reproduction)

tonemapping using bilateral filtering (I

think)

Modern DSLR sensors capture about 3 stops of dynamic range.• Tonemap single RAW file instead of using camera’s default rendering.

Page 91: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Tonemapping for a single image

Careful not to “tonemap” noise.• Why is this not a problem

with multi-exposure HDR?

Modern DSLR sensors capture about 3 stops of dynamic range.• Tonemap single RAW file instead of using camera’s default rendering.

Page 92: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

Some notes about HDR and tonemapping

Page 93: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

A note of caution

• HDR photography can produce very visually compelling results

Page 94: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 95: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 96: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 97: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

A note of caution

• HDR photography can produce very visually compelling results

• It is also a very routinely abused technique, resulting in awful results

Page 98: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 99: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 100: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 101: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase
Page 102: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

A note of caution

• HDR photography can produce very visually compelling results

• It is also a very routinely abused technique, resulting in awful results

• The problem is tonemapping, not HDR itself

Page 103: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

A note about HDR today

• Most cameras (even phone cameras) have automatic HDR modes/apps

• Popular-enough feature that phone manufacturers are actively competing about which one has the best HDR

• The technology behind some of those apps (e.g., Google’s HDR+) is published in SIGGRAPH and SIGGRAPH Asia conferences

Page 104: Tonemapping and bilateral filtering - Computer Graphicsgraphics.cs.cmu.edu/courses/15-463/2018_fall/lectures/lecture6.pdf · texture decrease texture increase large texture increase

ReferencesBasic reading:• Szeliski textbook, Sections 10.1, 10.2. Reinhard et al., “Photographic Tone Reproduction for Digital Images,” SIGGRAPH 2002.

The photographic tonemapping paper, including a very nice discussion of the zone system for film.• Durand and Dorsey, “Fast bilateral filtering for the display of high-dynamic-range images,” SIGGRAPH 2002.

The paper on tonemapping using bilateral filtering.• Paris et al., “A Gentle Introduction to the Bilateral Filter and Its Applications,” SIGGRAPH 2007-08, CVPR 2008

Short course on the bilateral filter, including discussion of fast implementations, https://people.csail.mit.edu/sparis/bf_course/

• Fattal et al., “Gradient Domain High Dynamic Range Compression,” SIGGRAPH 2002.The paper on gradient-domain tonemapping.

Additional reading:• Reinhard et al., “High Dynamic Range Imaging, Second Edition: Acquisition, Display, and Image-Based Lighting,” Morgan

Kaufmann 2010.A very comprehensive book about everything relating to HDR imaging and tonemapping.

• Kuang et al., “Evaluating HDR rendering algorithms,” TAP 2007.One of many, many papers trying to do a perceptual evaluation of different tonemapping algorithms.

• Hasinoff et al., “Burst photography for high dynamic range and low-light imaging on mobile cameras,” SIGGRAPH Asia 2016.The paper describing Google’s HDR+.

• Paris et al., “Local Laplacian Filters: Edge-aware Image Processing with a Laplacian Pyramid,” SIGGRAPH 2011 and CACM 2015.The paper on local Laplacian pyramids.