• 沒有找到結果。

Bilateral filtering

N/A
N/A
Protected

Academic year: 2022

Share "Bilateral filtering"

Copied!
152
0
0

加載中.... (立即查看全文)

全文

(1)

Bilateral Filters

Digital Visual Effectsg Yung-Yu Chuang

with slides by Fredo Durand, Ramesh Raskar, Sylvain Paris, Soonmin Bae

(2)

Bilateral filtering

Input

Input Log(Intensity) Log(Intensity) Bilateral Smoothing Bilateral Smoothing Gaussian

Gaussian Smoothing Smoothing

[Ben Weiss, Siggraph 2006]

[Ben Weiss, Siggraph 2006]

(3)

Image Denoising g g

noisy image naïve denoising Gaussian blur

better denoising edge preserving filter Gaussian blur edge-preserving filter

Smoothing an image without blurring its edges Smoothing an image without blurring its edges.

(4)

A Wide Range of Options g p

• Diffusion, Bayesian, Wavelets… Diffusion, Bayesian, Wavelets…

– All have their pros and cons.

Bil t l filt

• Bilateral filter

– not always the best result [Buades 05] but often good – easy to understand, adapt and set up

(5)

Basic denoising

Noisy input Median 5x5

(6)

Basic denoising

Noisy input Bilateral filter 7x7 window

(7)

Tone Mapping

[D d 02]

Tone Mapping

[D d 02]

[Durand 02]

[Durand 02]

HDR input

(8)

Tone Mapping

[D d 02]

Tone Mapping

[D d 02]

[Durand 02]

[Durand 02]

output

(9)

Photographic Style Transfer

[B 06]

Photographic Style Transfer

[B 06]

[Bae 06]

[Bae 06]

input

(10)

Photographic Style Transfer

[B 06]

Photographic Style Transfer

[B 06]

[Bae 06]

[Bae 06]

output

(11)

Cartoon Rendition

[Winnemöller 06]

Cartoon Rendition

[Winnemöller 06]

[Winnemöller 06]

[Winnemöller 06]

input

(12)

Cartoon Rendition

[Winnemöller 06]

Cartoon Rendition

[Winnemöller 06]

[Winnemöller 06]

[Winnemöller 06]

6 papers at 6 papers at p p

SIGGRAPH’07 p p

SIGGRAPH’07 SIGGRAPH 07 SIGGRAPH 07

output

(13)

Gaussian Blur

per-pixel multiplication

input

*

output

average average

(14)

input

(15)

box average

(16)

Gaussian blur

(17)

Equation of Gaussian Blur Equation of Gaussian Blur

Same idea: weighted average of pixels.

 

G I

I

GB [ ]

p

|| p q ||

q

normalized

S q

normalized Gaussian function 1

0

(18)

Gaussian Profile

G (x) 1 exp x2 

Gaussian Profile

pixel



 2 2 2 exp

)

(   

x G

weight

pixel position unrelated

pixels unrelated

pixels

uncertain pixels uncertain

pixels

related pixels

(19)

Spatial Parameter Spatial Parameter

 

S

I G

I GB

q

q

p

|| p q ||

]

[

input

size of the window

S q

small large

small large

limited smoothing strong smoothing

(20)

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

(21)

Properties of Gaussian Blur

• Weights independent of spatial location

– linear convolution

– well-known operation

– efficient computation (recursive algorithm, FFT…)

(22)

Properties of Gaussian Blur

• Does smooth images

B h h

input

• But smoothes too much:

edges are blurred.

– Only spatial distance matters – No edge term

output

 

S

I G

I GB

q

q

p

|| p q ||

]

[

space

S

q space

(23)

Blur Comes from Averaging across Edges

*

input output

*

*

S G i k l h

Same Gaussian kernel everywhere.

(24)

Bilateral Filter No Averaging across Edges

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

*

input output

*

*

Th k l h d d th i t t

The kernel shape depends on the image content.

(25)

Bilateral Filter Definition Bilateral Filter Definition

not new new

new

Same idea: weighted average of pixels.

   

S

I I

I G

W G I

BF

q

q q

p

p

1 || p q || | |

]

[

s r

i ht i ht

li ti

W

p qS

space weight range weight I

normalization factor

(26)

Illustration a 1D Image

• 1D image = line of pixelsg p

• Better visualized as a plot

pixel intensity

pixel position pixel position

(27)

Gaussian Blur and Bilateral Filter

Gaussian blur

p

q GB[I]p

G||p q ||Iq

space space

q

 

S q

q

p

Bilateral filter

[Aurich 95 Smith 97 Tomasi 98]

p

 

G G I I I

I

BF 1 || || | |

] [

[Aurich 95, Smith 97, Tomasi 98]

rap

space range normalization

 

S

I I

I G

W G I

BF

q

q q

p p

p 1 || p q || | |

]

[ s r

ange

q

space

(28)

Bilateral Filter on a Height Field

   

G G I I I

I W

BF p 1 || p q || | p q | q

]

[

s r

Wp qS p q q

p s r

output input

reproduced from [Durand 02]

(29)

Space and Range Parameters

1    

S

I I

I G

W G I

BF

q

q q

p p

p

1 || p q || | |

]

[

s r

• space  : spatial extent of the kernel size of

p q

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

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

(30)

Influence of Pixels

Only pixels close in space and in range are considered.

space

range range

p

p

(31)

= 0 1 = 0 25

r = 

(G i bl )

Exploring the Parameter Space Exploring the Parameter Space

r = 0.1 r = 0.25 (Gaussian blur)

s = 2

input

s = 6

s = 18

(32)

= 0 1 = 0 25

r = 

(G i bl )

Varying the Range Parameter Varying the Range Parameter

r = 0.1 r = 0.25 (Gaussian blur)

s = 2

input

s = 6

s = 18

(33)

input

(34)

r

= 0.1

(35)

r

= 0.25

(36)

r

= 

(G i bl )

(Gaussian blur)

(37)

= 0 1 = 0 25

r = 

(G i bl )

Varying the Space Parameter Varying the Space Parameter

r = 0.1 r = 0.25 (Gaussian blur)

s = 2

input

s = 6

s = 18

(38)

input

(39)

s

= 2

(40)

s

= 6

(41)

s

= 18

(42)

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

(43)

Iterating the Bilateral Filter

] [I

BF

I

(n 1)

BF [ I

(n)

] I

• Generate more piecewise-flat images

• Often not needed in computational photo, but could be useful for applications such as NPR.pp

(44)

input

(45)

1 iteration

(46)

2 iterations

(47)

4 iterations

(48)

Advantages of Bilateral Filter

• Easy to understand

W i ht d f b i l – Weighted mean of nearby pixels

• Easy to adapt

– Distance between pixel values

• Easy to set upEasy to set up

– Non-iterative

(49)

Hard to Compute

• Nonlinear

 

S

I I

I G

W G I

BF

q

q q

p p

p 1 || p q || | |

]

[ s r

• Complex, spatially varying kernels

Cannot be precomputed no FFT

S p q

– Cannot be precomputed, no FFT…

• Brute-force implementation is slow > 10min

(50)

But Bilateral Filter is Nonlinear

• Slow but some accelerations exist:

– [Elad 02]: Gauss-Seidel iterations

• Only for many iterations

– [Durand 02, Weiss 06]: fast approximation

• No formal understanding of accuracy versus speed

• [Weiss 06]: Only box function as spatial kernel

(51)

A Fast Approximation f th Bil t l Filt

of the Bilateral Filter

using a Signal Processing using a Signal Processing

Approach Approach

Sylvain Paris and Frédo Durand

Computer Science and Artificial Intelligence Laboratory Massachusetts Institute of Technology

(52)

Definition of Bilateral Filter Definition of Bilateral Filter

• [Smith 97, Tomasi 98]

I t R lt

• Smoothes an image and preserves edges

Input Result

• Weighted average of neighbors

• Weights

– Gaussian on space distance – Gaussian on range distance – sum to 1

space range

space range

(53)

Contributions

Li k ith

linear filtering

• Link with

linear filtering

Fast

and

accurate

approximation

(54)

Intuition on 1D Signal

BF

(55)

Basic idea

1D Gaussians

   

G G I I I

I W

BF p 1 q;p, s q ; p , r q ]

[

  

Wp qS q p q

p

(56)

Basic idea

1D Gaussians

   

G G I I I

I W

BF p 1 q;p, s q ; p , r q ]

[

  

Wp qS q p q

p

 

1

]

[I G I I I

BF

2D Gaussians

 



' '

,

' , r

s , ,

,

; ,

] [

S I

I I

I I

W G I

BF

q

q

q

q p

q p

p q p

 

a special 2D i

2D image

(57)

Intuition on 1D Signal

BF

(58)

Intuition on 1D Signal

Weighted Average of Neighbors

p

Weighted Average of Neighbors

weights p

weights applied to pixels

• Near and similar pixels have influence.

• Far pixels have no influence.

• Pixels with different value have no influence.

(59)

Link with Linear Filtering

1 Handling the Division

p

1. Handling the Division

p

sum of weights

Handling the division with a

projective space

.

(60)

Formalization: Handling the Division g

• Normalizing factor as homogeneous coordinate

• Normalizing factor as homogeneous coordinate

• Multiply both sides by

(61)

Formalization: Handling the Division

with Wq=1

• Similar to homogeneous coordinates in projective space

in projective space

• Division delayed until the end

• Division delayed until the end

• Next step: Adding a dimension to make a

• Next step: Adding a dimension to make a convolution appear

(62)

Link with Linear Filtering

2 Introducing a Convolution space: 1D Gaussian

 range: 1D Gaussian

p

2. Introducing a Convolution  range: 1D Gaussian combination: 2D Gaussian

p

q

space range

(63)

Link with Linear Filtering

2 Introducing a Convolution space: 1D Gaussian

range: 1D Gaussian

p

2. Introducing a Convolution range: 1D Gaussian combination: 2D Gaussian

p

q

space x range

Corresponds to a 3D Gaussian on a 2D image.

(64)

Link with Linear Filtering

2 Introducing a Convolution 2. Introducing a Convolution

black = zero sum all values

G i

space-range Gaussian

sum all values multiplied by kernel  convolution

(65)

Link with Linear Filtering

2 Introducing a Convolution 2. Introducing a Convolution

result of the convolution result of the convolution

G i

space-range Gaussian

(66)

Link with Linear Filtering

2 Introducing a Convolution 2. Introducing a Convolution

result of the convolution result of the convolution

G i

space-range Gaussian

(67)

higher dimensional functions

w i w

w i w

Gaussian convolution

division

slicing

(68)

Reformulation: Summaryy

1. Convolution in higher dimension

• expensive but well understood (linear, FFT, etc)

2. Division and slicing 2. Division and slicing

• nonlinear but simple and pixel-wise

Exact reformulation

Exact reformulation

(69)

higher dimensional functions

w i w

w i w

Gaussian convolution

Low-pass filter

division

slicing

(70)

higher dimensional functions

w i w

w i w

D O W N S A M P L E

Gaussian convolution

U P S A M P L E

division

slicing

(71)

Fast Convolution by Downsampling

• Downsampling cuts frequencies

• Downsampling cuts frequencies above Nyquist limit

Less data to process – Less data to process – But induces error

• Evaluation of the approximation

– Precision versus running time – Visual accuracy

(72)

Accuracy versus Running Time

• Finer sampling increases accuracy.

• More precise than previous work.p p

PSNR as function of Running Time

Digital photograph photograph 1200  1600

Straightforward Straightforward implementation is over 10 minutes.

(73)

Visual Results

• Comparison with previous work [Durand 02]

– running time = 1s for both techniques

i t t BF lt k

1200  1600 – running time = 1s for both techniques

input exact BF our result prev. work

difference 0.1

difference with exact computation (intensities in [0:1]) 0

(74)

Conclusions

hi h di i  “b tt ” t ti

higher dimension  “better” computation

Practical gain Theoretical gain

• Interactive running time

• Visually similar results

• Link with linear filters

• Separation linear/nonlinear

• Visually similar results

• Simple to code (100 lines)

• Separation linear/nonlinear

• Signal processing framework

(75)

Two-scale Tone Management Two-scale Tone Management

for Photographic Look g p

Soonmin Bae, Sylvain Paris, and Frédo Durand MIT CSAIL

MIT CSAIL

(76)

Ansel Adams

Ansel Adams, Clearing Winter Storm

(77)

An Amateur Photographer

(78)

A Variety of Looks

(79)

Goals

• Control over photographic look

• Transfer “look” from a model photop

For example For example, we want

with the look of

(80)

Aspects of Photographic Look

• Subject choice

• Framing and compositiong p

 Specified by input photos

Input

• Tone distribution and contrast

Input

Modified based on model photos

Model

(81)

Tonal Aspects of Look

Ansel Adams Kenro Izu

(82)

Tonal aspects of Look - Global Contrast

Ansel Adams Kenro Izu

High Global Contrast Low Global Contrast

(83)

Tonal aspects of Look - Local Contrast

Ansel Adams Kenro Izu

Variable amount of texture Texture everywhere

(84)

Overview

Model

Input Image Result

Input Image Result

• Transfer look between photographsTransfer look between photographs

– Tonal aspects

(85)

Overview

Global contrast

Result Input

Image

Local contrast l b l d l l

• Separate global and local contrast

(86)

Global contrast

Overview

Split Careful

combination

P t

Input Image

Post- process

Local contrast

Result

(87)

Global contrast

Overview

Split Careful

combination

P t

Input Image

Post- process

Local contrast

Result

(88)

Split Global vs. Local Contrast

• Naïve decomposition: low vs. high frequencyp g q y

– Problem: introduce blur & halos

Halo Blur

Low frequency High frequency

Low frequency High frequency

Global contrast Local contrast

(89)

Bilateral Filter

• Edge-preserving smoothing [Tomasi 98]g p g g [ ]

• We build upon tone mapping [Durand 02]

After bilateral filtering Residual after filtering After bilateral filtering Residual after filtering

Global contrast Local contrast

(90)

Bilateral Filter

• Edge-preserving smoothing [Tomasi 98]g p g g [ ]

• We build upon tone mapping [Durand 02]

BASE layer DETAIL layer

After bilateral filtering Residual after filtering After bilateral filtering Residual after filtering

Global contrast Local contrast

(91)

Global contrast

Bil t l Careful

combination

P t Bilateral

Filter

Input Image

Post- process

Local contrast

Result

(92)

Global contrast

Bil t l Careful

combination

P t Bilateral

Filter

Input Image

Post- process

Local contrast

Result

(93)

Global Contrast

• Intensity remapping of base layer

Remapped intensity

Input base Input intensity After remapping

(94)

Global Contrast (Model Transfer) ( )

• Histogram matching

• Histogram matching

– Remapping function given input and model histogram input and model histogram Model

base

Input Output

Input base

Output base

(95)

Global contrast

Intensity Intensity matching

Bil t l Careful

combination

P t Bilateral

Filter

Input Image

Post- process

Local contrast

Result

(96)

Global contrast

Intensity Intensity matching

Bil t l Careful

combination

P t Bilateral

Filter

Input Image

Post- process

Local contrast

Result

(97)

Local Contrast: Detail Layer

• Uniform control:Uniform control:

– Multiply all values in the detail layer

I t B 3 D t il

Input Base + 3  Detail

(98)

The amount of local contrast is not uniform

is not uniform

Smooth region

Textured region Textured region

(99)

Local Contrast Variation

• We define “textureness”: amount of local contrast

– at each pixel based on surrounding region

Smooth region

 Low textureness

Textured region Textured region

 High textureness

(100)

Textureness”: 1D Example

Textured region

Smooth region Textured region

 Large high-frequency Previous work:

Low pass of |H|

Low pass of |H|

Textured region

 Hi h t t g

 Small high-frequency [Li 05, Su 05][Li 05, Su 05]

 High textureness

Smooth region L t t

Input signal

 Low textureness

High frequency H Amplitude |H| Edge-preserving Input signal High frequency H Amplitude |H| Edge preserving

filter

(101)

Textureness

Input Textureness

Input Textureness

(102)

Textureness Transfer

Step 1:

f

Model Model Histogram transfer texturenesstextureness

Hist transfer Input

Input t t

t t

Desired Desired t t

t t Hist. transfer

textureness

textureness texturenesstextureness

x 0.5

Step 2:

x 2.7

Scaling detail layer (per pixel) to match

desired textureness

x 4.3

Input detail Output detail desired textureness

(103)

Global contrast

Intensity Intensity matching

Bil t l Careful

combination

P t Bilateral

Filter

Input Image

Post- process

Textureness matching

Local contrast

Result

(104)

Global contrast

Intensity Intensity matching

Bil t l Careful

combination

P t Bilateral

Filter

Input Image

Post- process

Textureness matching

Local contrast

Result

(105)

A Non Perfect Result

• Decoupled and large modifications (up to 6x)

Limited defects may appear

input (HDR)

result after

global and local adjustments

(106)

Intensity Remapping

S i i i b id di l bl

• Some intensities may be outside displayable range.

 Compress histogram to fit visible range.

corrected result remapped

intensities initial

result

(107)

Preserving Details

1. In the gradient domain:

C di t lit d f i t d t

– Compare gradient amplitudes of input and current – Prevent extreme reduction & extreme increase

l h

2. Solve the Poisson equation.

corrected result remapped

intensities initial

result

(108)

Effect of Detail Preservation

uncorrected result corrected result

(109)

Global contrast

Intensity Intensity matching

Bil t l

P t Bilateral

Filter

Constrained Poisson

Input Image

Post- process

Textureness matching

Local contrast

Result

(110)

Global contrast

Intensity Intensity matching

Bil t l Bilateral Filter

Constrained Poisson

Input P Image

Post- process

Textureness matching

Local contrast

Result

(111)

Additional Effects

model

• Soft focus (high frequency manipulation)

• Film grain (texture synthesis [Heeger 95])

• Film grain (texture synthesis [Heeger 95])

• Color toning (chrominance = f (luminance))

before after

before

effects effects

(112)

Intensity

Global contrast

Intensity matching

Bil t l Bilateral Filter

Constrained Poisson

S ft f

Input Image

Soft focus Toning

Grain Textureness

matching

Local contrast

Result

(113)

Intensity

Global contrast

Recap

Intensity matching

Bil t l Bilateral Filter

Constrained Poisson

S ft f

Input Image

Soft focus Toning

Grain Textureness

matching

Local contrast

Result

(114)

Results

U id i d d l h h

User provides input and model photographs.

Our system automatically produces the result.

Running times:

Running times:

– 6 seconds for 1 MPixel or less 23 seconds for 4 MPixels

– 23 seconds for 4 MPixels

multi-grid Poisson solver and fast bilateral filter [Paris

06]]

(115)

Input Model

Result

(116)

Input

Result

(117)

Input Model

Result

(118)

Comparison with Naïve Histogram Matching

Input

Input ModelModel

Snapshot

Snapshot, Alfred Stieglitz, Alfred Stieglitz

p

p SnapshotSnapshot, Alfred Stieglitz, Alfred Stieglitz

Our result Our result Naïve Histogram Matching

Naïve Histogram Matching Local contrast, sharpness unfaithful

(119)

Comparison with Naïve Histogram Matching

Input Input

Model Model

Clearing Winter Storm, Ansel Adams

p p

Our Result Our Result Histogram Matching

Histogram Matching

Local contrast too low

(120)

Color Images

• Lab color space: modify only luminance

Input

Input OutputOutput

(121)

Limitations

• Noise and JPEG artifacts

– amplified defectsamplified defects

• Can lead to unexpected

• Can lead to unexpected

results if the image content is too different from the model too different from the model

– Portraits, in particular, can suffer

suffer

(122)

Conclusions

T f “l k” f d l h

• Transfer “look” from a model photo

• Two-scale tone management

– Global and local contrastGlobal and local contrast

– New edge-preserving textureness – Constrained Poisson reconstructionConstrained Poisson reconstruction – Additional effects

(123)

Video Enhancement Using

Per Pixel Exposures (Bennett 06) Per Pixel Exposures (Bennett, 06)

From this video:

ASTA: Adaptive SS ti

SSpatio- T

Temporal

A l ti Filt Accumulation Filter

(124)

Joint bilateral filtering

(125)

Flash / No-Flash Photo Improvement (Petschnigg04) (Eisemann04)

(Petschnigg04) (Eisemann04)

Merge best features: warm, cozy candle light (no-flash)g , y g ( ) low-noise, detailed flash image

(126)

Overview

Basic approach of both flash/noflash papers

Remove noise + details

Basic approach of both flash/noflash papers

Remove noise + details from image A,

Keep as image A Lighting

No-flash ---

Obtain noise-free details

o as

Obtain noise free details from image B,

Discard Image B Lighting Result

(127)

Petschnigg:

• Flash

(128)

Petschnigg:

• No Flash,

(129)

Petschnigg:

• Result

(130)

Our Approach

Registration Registration

(131)

Our Approach

Decomposition

(132)

Decomposition

Color / Intensity:

= *

original intensity color

(133)

Our Approach

Decomposition

(134)

Our Approach

Decoupling

(135)

Decoupling

• Lighting : Large-scale variation

T S ll l i i

• Texture : Small-scale variation

Texture Lighting

Lighting

(136)

Large-scale Layer

• Bilateral filter – edge preserving filter

• Bilateral filter – edge preserving filter

Smith and Brady 1997; Tomasi and Manducci 1998; Durand et al. 2002

I t O t t

Input Output

(137)

Large-scale Layer

• Bilateral filter

(138)

Cross Bilateral Filter

• Similar to joint bilateral filter by Petschnigg et al

al.

• When no-flash image is too noisyg y

• Borrow similarity from flash image

 edge stopping from flash image

Bilateral Cross Bilateral

(139)

Detail Layer

/ =

/ =

Intensity Large-scale Detail

Recombination: Large scale * Detail = Intensity

Recombination: Large scale * Detail = Intensity

(140)

Recombination

* =

* =

Large-scale Detail Intensity

No-flash Flash Result

Recombination: Large scale * Detail = Intensity

Recombination: Large scale * Detail = Intensity

(141)

Recombination

shadows shadows

** ~ ~

Intensity Color Result

Result Flash

Recombination: Intensity * Color = Original

(142)

Our Approach

(143)

Our Approach

Shadow

Detection/Treatment Detection/Treatment

(144)

Results

No-flash

Result Flash

(145)

Joint bilateral upsampling

(146)

Joint bilateral upsampling

(147)

Joint bilateral upsampling

(148)

Joint bilateral upsampling

(149)

Joint bilateral upsampling

(150)

Joint bilateral upsampling

(151)

Joint bilateral upsampling

(152)

Joint bilateral upsampling

參考文獻

相關文件

‹ Based on the coded rules, facial features in an input image Based on the coded rules, facial features in an input image are extracted first, and face candidates are identified.

vertices’ edges, in this shortest path, the left edge must be relaxed before the right edge.  One phase of improvement

 Calculating the expected total edge number for one left path started at one problem with m’ edges.  Evaluating the total edge number for all right sub-problems #

Accordingly, we reformulate the image deblur- ring problem as a smoothing convex optimization problem, and then apply semi-proximal alternating direction method of multipliers

Based on a class of smoothing approximations to projection function onto second-order cone, an approximate lower order penalty approach for solving second-order cone

In summary, the main contribution of this paper is to propose a new family of smoothing functions and correct a flaw in an algorithm studied in [13], which is used to guarantee

Specifically, in Section 3, we present a smoothing function of the generalized FB function, and studied some of its favorable properties, including the Jacobian consistency property;

Specifically, in Section 3, we present a smoothing function of the generalized FB function, and studied some of its favorable properties, including the Jacobian consis- tency