Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat...

60
Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam Roweis, Barun Singh Massachusetts Institute of Technology

Transcript of Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat...

Page 1: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Removing blur due to camera shake from images.

William T. Freeman

Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam Roweis, Barun Singh

Massachusetts Institute of Technology

Page 2: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Overview

Original Our algorithm

Page 3: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Close-up

Original Naïve Sharpening Our algorithm

Page 4: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Let’s take a photo

Blurry result

Page 5: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Slow-motion replay

Page 6: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Slow-motion replay

Motion of camera

Page 7: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Image formation process

= ⊗

Blurry image Sharp image

Blur kernel

Input to algorithm Desired output

ConvolutionoperatorModel is approximation

Page 8: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Why is this hard?

Simple analogy:11 is the product of two numbers.What are they?

No unique solution: 11 = 1 x 1111 = 2 x 5.511 = 3 x 3.667 etc…..

Need more information !!!!

Page 9: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Multiple possible solutions

= ⊗

Blurry image

Sharp image Blur kernel

= ⊗

= ⊗

Page 10: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Is each of the images that follow sharp or blurred?

Page 11: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.
Page 12: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.
Page 13: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.
Page 14: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Another blurry one

Page 15: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.
Page 16: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.
Page 17: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Natural image statistics

Histogram of image gradients

Characteristic distribution with heavy tails

Page 18: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Blury images have different statistics

Histogram of image gradients

Page 19: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Parametric distribution

Histogram of image gradients

Use parametric model of sharp image statistics

Page 20: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Uses of natural image statistics

• Denoising [Roth and Black 2005]

• Superresolution [Tappen et al. 2005]

• Intrinsic images [Weiss 2001]

• Inpainting [Levin et al. 2003]

• Reflections [Levin and Weiss 2004]

• Video matting [Apostoloff & Fitzgibbon 2005]

Corruption process assumed known

Page 21: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Existing work on image deblurring

Software algorithms:– Extensive literature in signal processing

community– Mainly Fourier and/or Wavelet based– Strong assumptions about blur

not true for camera shake

– Image constraints are frequency-domain power-laws

Assumed forms of blur kernels

Page 22: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.
Page 23: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

A focus on image constraints, not image priors

Page 24: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Some image constraints/priors

Page 25: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Toy example: observed “image”:

1.0

0.0

Page 26: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

1.0

0.0

Toy example: observed “image”:

Page 27: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Toy example: observed “image”:

1.0

0.0

Page 28: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Three sources of information

1. Reconstruction constraint:

=⊗

Input blurry imageEstimated sharp imageEstimatedblur kernel

3. Blur prior:

Positive&

Sparse

2. Image prior:

Distribution of gradients

Page 29: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Prior on image gradients (mixture of Gaussians giving a

Laplacian-like distribution)

Distribution of gradients (log-scale)Green curve is our mixture of gaussians fit.

Page 30: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Prior on blur kernel pixels (mixture of exponentials)

b

P(b)

Page 31: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

How do we use this information?

Obvious thing to do:– Combine 3 terms into an objective function

– Run conjugate gradient descent

– This is Maximum a-Posteriori (MAP)

Page 32: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Maximum A-Posterioriy – observed blurry imagex – unobserved sharp imageb – blur kernel

i – image patch indexf – derivative filter

Likelihood Latent image prior Blur prior

Assumption: all pixels independent of one another

Sparse and

Page 33: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Results from MAP estimation

Maximum a-Posteriori (MAP)Our method: Variational Bayes

Input blurry image

Page 34: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Variational Bayes

http://citeseer.ist.psu.edu/cache/papers/cs/16537/http:zSzzSzwol.ra.phy.cam.ac.ukzSzjwm1003zSzspringer_chapter8.pdf/miskin00ensemble.pdf

Page 35: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Miskin and Mackay, 2000

Page 36: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Setup of variational approachNeed likelihood and prior in same space, so use gradients:

Likelihood

Prior on latent image gradients – mixture of Gaussians

Prior on blur elements – mixture of Exponentialsi – image pixelj – blur pixel

We use C=4, D=4

Also have Gamma hyperpriors on

Page 37: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Variational inference• Approximate posterior with

• Cost function

• Assume

• Use gradient descent, alternating between updating while marginalizing out over and vice versa

• Adapted code from Miskin & Mackay 2000

is Gaussian on each pixel

is rectified Gaussian on each pixel

Page 38: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Variational Bayesian method

Based on work of Miskin & Mackay 2000

Keeps track of uncertainty in estimates of image and blur by using a distribution instead of a single estimate

Helps avoid local maxima and over-fitting

Page 39: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Variational Bayes

Variational Bayesian method

Maximum a-Posteriori (MAP)

Pixel intensity

Score

Objective function for a single variable

Page 40: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

MAP vs Variational

MAP

Variational

MAP using variational initialization

Page 41: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Blurry synthetic image

Page 42: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Inference – initial scale

Page 43: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Inference – scale 2

Page 44: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Inference – scale 3

Page 45: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Inference – scale 4

Page 46: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Inference – scale 5

Page 47: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Inference – scale 6

Page 48: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Inference – final scale

Page 49: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Our output

Page 50: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Ground truth

Page 51: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Matlab’s deconvblind

Page 52: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

True kernel Estimated kernel

Page 53: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Tried the same algorithm on an image of real camera blur, with very similar blur kernel

Failure!

Page 54: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Whiteboard scene:

Does camera shake give a stationary blur kernel?

8 different people, handholding camera, using 1 second exposure

Page 55: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

View of the dots at each corner in photos taken by 4 people

Topleft

Bot.left

Topright

Bot.right

Person 1

Person 3 Person 4

Person 2

Page 56: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Tonescale: output from camera

Page 57: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Linear response to light intensities looks like this

Page 58: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Overview of algorithm

Input image

1. Pre-processing

2. Kernel estimation- Multi-scale approach

3. Image reconstruction- Standard non-blind deconvolution

routine

Page 59: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

Preprocessing

Convert tograyscale

Input image

Remove gammacorrection

User selects patch from image

Bayesian inference too slow to run on whole image

Infer kernel from this patch

Page 60: Removing blur due to camera shake from images. William T. Freeman Joint work with Rob Fergus, Anat Levin, Yair Weiss, Fredo Durand, Aaron Hertzman, Sam.

InitializationInput image

Initialize 3x3 blur kernel

Initial blur kernelBlurry patch Initial image estimate

Convert tograyscale

Remove gammacorrection

User selects patch from image