56
CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Embed Size (px)

Citation preview

Page 1: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

CSCE 441: Computer GraphicsImage Filtering

Jinxiang Chai

Page 2: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Outline

Image Processing

- Gaussian filtering

- Median filtering

- Bilateral filtering

Page 3: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtering

• In signal processing, a filter is a process that removes from a signal some unwanted component or feature

Page 4: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

1D Signal Filtering

Page 5: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

2D Image Filtering

Page 6: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

2D Image Filtering

Page 7: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Image Filtering

Image filtering: change range of image g(x) = h(f(x))

f

x

hf

x

f

x

hf

x

Image warping: change domain of imageg(x) = f(h(x))

Page 8: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Image Filtering

Image filtering: change range of image g(x) = h(f(x))

Image warping: change domain of imageg(x) = f(h(x))

hf g

hf g

Page 9: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtering in Spatial Domain

=

Filter functionInput imageFiltered image

Page 10: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Gaussian Filtering in Spatial Domain

Discrete approximation to Gaussian function with σ =1.0

Page 11: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtering in Spatial Domain

Discrete approximation to Gaussian function with σ =1.0

Page 12: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtering in Spatial Domain

Discrete approximation to Gaussian function with σ =1.0

Page 13: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtering in Spatial Domain

Discrete approximation to Gaussian function with σ =1.0

Page 14: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtering in Spatial Domain

Discrete approximation to Gaussian function with σ =1.0

Filtered_I45 = Xwindownpixels

Page 15: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtering

input Gaussian filter

Page 16: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Median Filter

• For each neighbor in image, sliding the window

• Sort pixel values• Set the center pixel to the median

Page 17: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Median Filter

input Gaussian filter Median filter

Page 18: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Median Filter Examples

input Median 7X7

Page 19: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Median Filter Examples

Median 11X11Median 3X3

Page 20: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Median Filter Examples

Median 11X11Median 3X3

Straight edges kept

Sharp features lost

Page 21: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Median Filter Properties

Can remove outliers (peppers and salts)

Window size controls size of structure

Preserve some details but sharp corners and edges might get lost

Page 22: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Comparison of Mean, Gaussian, and Median

original Mean with 6 pixels

Page 23: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Comparison of Mean, Gaussian, and Median

original Gaussian with 6 pixels

Page 24: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Comparison of Mean, Gaussian, and Median

original Median with 6 pixels

Page 25: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Page 26: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Page 27: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Median: preserves some details, good at removing strong noise

Page 28: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Median: preserves some details, good at removing strong noise

Can we find a filter that not only smooths regions but preserves edges?

Page 29: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Median: preserves some details, good at removing strong noise

Can we find a filter that not only smooths regions but preserves edges?

- yes, bilateral filter

Page 30: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Outline

Image Processing

- Gaussian filtering

- Median filtering

- Bilateral filtering

Page 31: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

What Is Bilateral Filter?

Bilateral

- Affecting or undertaken by two sides equally

Property:

- Convolution filter

- Smooth image but preserve edges

- Operates in the domain and the range of image

Page 32: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Example

Gaussian filter Bilateral filter

Page 33: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Example

Gaussian filter Bilateral filter

Page 34: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

1D Graphical ExampleCenter Sample u

It is clear that in weighting this neighborhood, we would like to preserve the step

Neighborhood

I(p)

p

)(uneighborp

Page 35: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

The Weights

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Page 36: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filtered Values

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Page 37: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Edges Are Smoothed

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Page 38: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

What Causes the Problem?

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Page 39: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

What Causes the Problem?

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Same weights for these two pixels!!

Page 40: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

The Weights

)2

))()((exp()( 2

2

s

s

pIuIpW

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Page 41: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral filter

2

2 2

2

2 2

2 2

2 2

( )

'

c s

c s

I u I pu p

p N u

I u I pu p

p N u

e e I p

I u

e e

Denoise Feature preserving

Normalization

Bilateral FilteringBilateral Filtering

Page 42: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Kernel Properties

• Per each sample, we can define a ‘Kernel’ that averages its neighborhood

• This kernel changes from sample to sample!• The sum of the kernel entries is 1 due to the

normalization,• The center entry in the kernel is the largest,• Subject to the above, the kernel can take any

form (as opposed to filters which are monotonically decreasing).

p sc

p sc

pWpW

pIpWpWuI

)(*)(

)(*)(*)()(

Page 43: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Filter Parameters

As proposed by Tomasi and Manduchi, the filter is controlled by 3 parameters:

The filter can be applied for several iterations in order to further strengthen its edge-preserving smoothing

N(u) – The neighbor size of the filter support,c – The variance of the spatial distances,s – The variance of the value distances,

)(

)(

)(*)(

)(*)(*)()(

uNp sc

uNp sc

pWpW

pIpWpWuI

Page 44: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter

input

Page 45: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter

input

Page 46: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter

input

Wc

Page 47: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter

input

Wc Ws

Page 48: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter

input

Wc Ws Ws*Wc

Page 49: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter

input

Wc Ws Ws*Wc

Output

Page 50: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Results

Original

Page 51: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Results

σc = 3, σs = 3

Page 52: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Results

σc = 6, σs = 3

Page 53: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Results

σc = 12, σs = 3

Page 54: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Results

σc = 12, σs = 6

Page 55: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Bilateral Filter Results

σc = 15, σs = 8

Page 56: CSCE 441: Computer Graphics Image Filtering Jinxiang Chai

Additional Comments

The bilateral filter is a powerful filter: - Can work with any reasonable distances

function Ws and Wc,

- Easily extended to higher dimension signals, e.g. Images, video, mesh, animation data etc.

- Easily extended to vectored-signals, e.g. Color images, etc.

[Fleishman et al, siggraph 03]Bilateral Mesh Denoising