A Gentle Introduction to Bilateral Filtering and its Applications...

Post on 18-Sep-2020

1 views 0 download

transcript

A Gentle Introductionto Bilateral Filteringand its Applications

A Gentle Introductionto Bilateral Filteringand its Applications

“Fixing the Gaussian Blur”: the Bilateral Filter

Sylvain Paris – MIT CSAIL

Blur Comes from Averaging across EdgesBlur Comes from Averaging across Edges

*

*

*

input output

Same Gaussian kernel everywhere.

Bilateral FilterNo Averaging across EdgesBilateral FilterNo Averaging across Edges

*

*

*

input output

The kernel shape depends on the image content.

[Aurich 95, Smith 97, Tomasi 98]

space weight

not new

range weight

I

new

normalizationfactor

new

Bilateral Filter Definition:an Additional Edge TermBilateral Filter Definition:an Additional Edge Term

( ) ( )−− IIGG qpqp ||||||rs σσ∑

=SW qp

1 IIBF qp][

Same idea: weighted average of pixels.

Illustration a 1D ImageIllustration a 1D Image

• 1D image = line of pixels

• Better visualized as a plot

pixelintensity

pixel position

space

Gaussian Blur and Bilateral FilterGaussian Blur and Bilateral Filter

space rangenormalization

Gaussian blur

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

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

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

space

spacerange

p

p

q

q

( )∑∈

−=S

IGIGBq

qp qp ||||][ σ

qqpp

Bilateral Filter on a Height FieldBilateral Filter on a Height Field

output input

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

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

pp

reproducedfrom [Durand 02]

Space and Range ParametersSpace 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 σσ

Influence of PixelsInfluence of Pixels

pp

Only pixels close in space and in range are considered.

space

range

σs = 2

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

(Gaussian blur)

σs = 6

σs = 18

input

Exploring the Parameter SpaceExploring the Parameter Space

σs = 2

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

(Gaussian blur)

σs = 6

σs = 18

input

Varying the Range ParameterVarying the Range Parameter

input

σr = 0.1

σr = 0.25

σr = ∞(Gaussian blur)

σs = 2

σs = 6

σs = 18

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

(Gaussian blur)

input

Varying the Space ParameterVarying the Space Parameter

input

σs = 2

σs = 6

σs = 18

How to Set the ParametersHow 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

A FewMore Advanced

Remarks

A FewMore Advanced

Remarks

Bilateral Filter Crosses Thin LinesBilateral 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

Iterating the Bilateral FilterIterating the Bilateral Filter

• Generate more piecewise-flat images

• Often not needed in computational photo.

][ )()1( nn IBFI =+

input

1 iteration

2 iterations

4 iterations

Bilateral Filtering Color ImagesBilateral Filtering Color Images

( ) ( )∑∈

−−=S

IIIGGW

IBFq

qqpp

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

( ) ( )∑∈

−−=S

GGW

IBFq

qqpp

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

For color images color difference

For gray-level images intensity difference

The bilateral filter isThe bilateral filter isextremely easy to adapt to your need.extremely easy to adapt to your need.

scalar

3D vector (RGB, Lab)

input

output

Hard to ComputeHard 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 σσ

Questions?Questions?