bilateral filtering, and non-local means denoisingerkut/bil717.s12/w09...bilateral filtering, and!...

65
Bilateral Filtering, and Non-local Means Denoising Erkut Erdem Acknowledgement: The slides are adapted from the course “A Gentle Introduction to Bilateral Filtering and its Applications” given by Sylvain Paris, Pierre Kornprobst, Jack Tumblin, and Frédo Durand (http://people.csail.mit.edu/sparis/bf_course/)

Upload: others

Post on 01-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Bilateral Filtering, and ���Non-local Means Denoising

Erkut Erdem

Acknowledgement: The slides are adapted from the course “A Gentle Introduction to Bilateral Filtering and its Applications” given by ���Sylvain Paris, Pierre Kornprobst, Jack Tumblin, and Frédo Durand (http://people.csail.mit.edu/sparis/bf_course/)

Page 2: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Notation and Definitions

•  Image = 2D array of pixels

•  Pixel = intensity (scalar) or color (3D vector)

•  Ip = value of image I at position: p = ( px , py )

•  F [ I ] = output of filter F applied to image I

x

y

Page 3: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Strategy for Smoothing Images

•  Images are not smooth because ���adjacent pixels are different.

•  Smoothing = making adjacent pixels��� look more similar.

•  Smoothing strategy��� pixel → average of its neighbors

Page 4: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Box Average

average  

input  

square  neighborhood  

output  

Page 5: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

sum  over  all  pixels  q

normalized  box  func8on  

intensity  at  pixel  q

result  at  pixel  p

Equation of Box Average

∑∈

−=S

IBIBAq

qp qp )(][ σ

0

Page 6: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Square Box Generates Defects •  Axis-aligned streaks •  Blocky results

input  

output  

Page 7: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Strategy to Solve these Problems

•  Use an isotropic (i.e. circular) window. •  Use a window with a smooth falloff.

box  window   Gaussian  window  

Page 8: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Gaussian Blur

average  

input  

per-­‐pixel  mul8plica8on  

output  *

Page 9: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

input  

Page 10: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

box  average  

Page 11: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Gaussian  blur  

Page 12: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

normalized  Gaussian  func8on  

Equation of Gaussian Blur

( )∑∈

−=S

IGIGBq

qp qp ||||][ σ

Same  idea:  weighted  average  of  pixels.  

0

1

Page 13: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

size  of  the  window  

Spatial Parameter

( )∑∈

−=S

IGIGBq

qp qp ||||][ σ

small  σ large  σ

input  

limited  smoothing   strong  smoothing  

Page 14: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

How to set σ

•  Depends on the application.

•  Common strategy: proportional to image size – e.g. 2% of the image diagonal – property: independent of image resolution

Page 15: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Properties of Gaussian Blur

•  Weights independent of spatial location

–  linear convolution

– well-known operation

– efficient computation (recursive algorithm, FFT…)

Page 16: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Properties of Gaussian Blur

•  Does smooth images •  But smoothes too much: ���

edges are blurred. – Only spatial distance matters

– No edge term

input  

output  

( )∑∈

−=S

IGIGBq

qp qp ||||][ σspace  

Page 17: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Blur Comes from ���Averaging across Edges

*

*

*

input   output  

Same  Gaussian  kernel  everywhere.  

Page 18: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Bilateral Filter���No Averaging across Edges

*

*

*

input   output  

The  kernel  shape  depends  on  the  image  content.  

[Aurich  95,  Smith  97,  Tomasi  98]  

Page 19: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

space  weight  

not  new  

range  weight  

I

new  

normaliza8on  factor  

new  

Bilateral Filter Definition: ���an Additional Edge Term

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

p qp ||||||1][rs σσ

Same  idea:  weighted  average  of  pixels.  

Page 20: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Illustration a 1D Image

•  1D image = line of pixels

•  Better visualized as a plot

pixel  intensity  

pixel  posi7on  

Page 21: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

space  

Gaussian Blur and Bilateral Filter

space   range  normaliza8on  

Gaussian  blur  

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

p qp ||||||1][rs σσ

Bilateral  filter  [Aurich  95,  Smith  97,  Tomasi  98]  

space  

space  range  

p

p

q

q

( )∑∈

−=S

IGIGBq

qp qp ||||][ σ

Page 22: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

qp

Bilateral Filter on a Height Field

output   input  

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

p qp ||||||1][rs σσ

p

reproduced  from  [Durand  02]  

Page 23: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Space and Range Parameters

•  space σs : spatial extent of the kernel, size of the considered neighborhood.

•  range σr : “minimum” amplitude of an edge

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

p qp ||||||1][rs σσ

Page 24: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Influence of Pixels

p

Only  pixels  close  in  space  and  in  range  are  considered.  

space  

range  

Page 25: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σs = 2

σs = 6

σs = 18

σr = 0.1 σr = 0.25 σr = ∞

(Gaussian blur)

input  

Exploring the Parameter Space

Page 26: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σs = 2

σs = 6

σs = 18

σr = 0.1 σr = 0.25 σr = ∞

(Gaussian blur)

input  

Varying the Range Parameter

Page 27: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

input  

Page 28: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σr = 0.1  

Page 29: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σr = 0.25  

Page 30: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σr = ∞ (Gaussian blur)  

Page 31: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σs = 2

σs = 6

σs = 18

σr = 0.1 σr = 0.25 σr = ∞

(Gaussian blur)

input  

Varying the Space Parameter

Page 32: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

input  

Page 33: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σs = 2  

Page 34: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σs = 6  

Page 35: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

σs = 18  

Page 36: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

How to Set the Parameters

Depends on the application. For instance:

•  space parameter: proportional to image size –  e.g., 2% of image diagonal

•  range parameter: proportional to edge amplitude –  e.g., mean or median of image gradients

•  independent of resolution and exposure

Page 37: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Bilateral Filter Crosses Thin Lines •  Bilateral filter averages across ��� features thinner than ~2σs

•  Desirable for smoothing: more pixels = more robust •  Different from diffusion that stops at thin lines

close-­‐up   kernel  

Page 38: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Iterating the Bilateral Filter

•  Generate more piecewise-flat images •  Often not needed in computational photo.

][ )()1( nn IBFI =+

Page 39: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

input  

Page 40: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

1  itera7on  

Page 41: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

2  itera7ons  

Page 42: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

4  itera7ons  

Page 43: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Bilateral Filtering Color Images

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

p qp ||||||1][rs σσ

( ) ( )∑∈

−−=S

GGW

IBFq

qqpp

p CCCqp ||||||||1][rs σσ

For  gray-­‐level  images    

For  color  images    

intensity  difference  

color  difference  

scalar  

3D  vector    (RGB,  Lab)  

input  

output  

Page 44: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Hard to Compute

•  Nonlinear

•  Complex, spatially varying kernels – Cannot be precomputed, no FFT…

•  Brute-force implementation is slow > 10min

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

p qp ||||||1][rs σσ

Additional Reading: Constant time O(1) Bilateral Filtering, F. Porikli, Proc. IEEE CVPR, 1998

Page 45: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Basic denoising Noisy  input   Bilateral  filter  7x7  window  

Page 46: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Bilateral  filter  

Basic denoising Median  3x3  

Page 47: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Bilateral  filter  

Basic denoising Median  5x5  

Page 48: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Basic denoising Bilateral  filter   Bilateral  filter  –  lower  sigma  

Page 49: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Bilateral  filter  

Basic denoising Bilateral  filter  –  higher  sigma  

Page 50: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Denoising

•  Small spatial sigma (e.g. 7x7 window) •  Adapt range sigma to noise level •  Maybe not best denoising method, but best

simplicity/quality tradeoff – No need for acceleration (small kernel)

– But the denoising feature in e.g. Photoshop is better

Page 51: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

Goal: Understand how does bilateral filter relates with other methods

Local  mode  filtering  

Robust  sta8s8cs  

Par8al  differen8al  equa8ons  

Bilateral  filter  

Additional Reading: Generalised Nonlocal Image Smoothing, ���L. Pizarro, P. Mrazek, S. Didas, S. Grewenig and J. Weickert, IJCV, 2010���

Page 52: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

New Idea: ���NL-Means Filter (Buades 2005)

•  Same goals: ‘Smooth within Similar Regions’

•  KEY INSIGHT: Generalize, extend‘Similarity’ – Bilateral: ��� Averages neighbors with similar intensities;

– NL-Means: ��� Averages neighbors with similar neighborhoods!

Page 53: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Method: ���Buades (2005)

•  For each and every pixel p:

Page 54: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Method: ���Buades (2005)

•  For each and every pixel p: ��� – Define a small, simple fixed size neighborhood;

Page 55: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

•  For each and every pixel p: ��� – Define a small, simple fixed size neighborhood; –  Define vector Vp: a list of neighboring pixel values.

NL-Means Method: ���Buades (2005)

Vp  =    

0.74  0.32  0.41  0.55  …  …  …  

Page 56: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Method: ���Buades (2005)

‘Similar’ pixels p, q à SMALL���

vector distance;

 ||  Vp  –  Vq  ||2    

p  

q  

Page 57: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Method: ���Buades (2005)

‘Dissimilar’ pixels p, q à LARGE���

vector distance;

 ||  Vp  –  Vq  ||2    

p  q  

q  

Page 58: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Method: ���Buades (2005)

‘Dissimilar’ pixels p, q à LARGE���

vector distance;

Filter with this!

 ||  Vp  –  Vq  ||2    

p  q  

Page 59: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Method: ���Buades (2005)

p, q neighbors define a vector distance;

Filter with this:���

No spatial term!

 ||  Vp  –  Vq  ||2     p  q  

( ) ( )∑∈

−−=S

IVVGGW

INLMFq

qqpp

p qp 2||||||||1][rs

σσ

Page 60: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Method: ���Buades (2005)

pixels p, q neighbors���Set a vector distance;

Vector Distance to p sets ���weight for each pixel q

 ||  Vp  –  Vq  ||2     p  q  

( )∑∈

−=S

IVVGW

INLMFq

qqpp

p2||||1][

r

σ

Page 61: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Filter (Buades 2005)

•  Noisy���source���image:

Page 62: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Filter (Buades 2005)

•  Gaussian���Filter

Low noise, Low detail

Page 63: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Filter (Buades 2005)

•  Anisotropic���Diffusion (Note ���

‘stairsteps’: ���~ piecewise���constant)

Page 64: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Filter (Buades 2005)

•  Bilateral ���Filter (better, but���

similar���‘stairsteps’: ���

Page 65: Bilateral Filtering, and Non-local Means Denoisingerkut/bil717.s12/w09...Bilateral Filtering, and! Non-local Means Denoising" Erkut Erdem !! Acknowledgement: The slides are adapted

NL-Means Filter (Buades 2005)

•  NL-Means: Sharp, Low noise, Few artifacts. ���