You are on page 1of 20

Grayscale Smoothing

Grayscale averaging = convolution with:


1/25 1/25 1/25 1/25 1/25 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25 1/25

3X3

5X5 Soft Averaging: Convolution with a Gaussian


-(x2+y2) e 22

Discrete case:
1 0 1 2 1 0 1 0 2 2 4 6 4 2 3 6 9 6 3 2 4 6 4 2 1 2 3 2 1

1/6 x

1 0

1/81 x

3 2 1

A separable kernel
1

What happens near the edges?

Option 1: Zero padding


0 0 0 1 2 3 4 5 0 0 0

4 10 16 22 22

Option 2: Wrap around


3 4 5 1 2 3 4 5 1 2 3 4 5

19 10 16 22 23 5

Option 3: Reflection
3 2 1 1 2 3 4 5 5 4 3 2

7 10 16 22 27 5
2

What is the size of the result?

Option 1: same
0 0 0 0 1 2 3

(size(A))

4 5

0 0

0 0

0 1

4 10 16 22 22 15

Option 2: full (size(A)+size(B)-1)


0 0 0 0 1 2 3 4 5 0 0 0 0 0

0 1

4 10 16 22 22 15

Option 3: valid
0 0 0 0 1 2 3

(size(A)-size(B)+1)
4 5 0 0 0 0 0

0 1

4 10 16 22 22 15
3

Normal vs Gaussian Grayscale Smoothing

Original Noisy image

3X3 Average

3X3 Gaussian Average

5X5 Average

5X5 Gaussian Average

7X7 Average

7X7 Gaussian Average

Smoothing with square averaging filter n=3

n=5

n=9

n=15

n=35

Median Filtering
S = neighborhood of pixel (x,y) g(x,y) = median {f(n,m)} (n,m)S

30

10 20

10 250 25 20 25 30

10, 10, 20, 20, 25, 25, 30, 30, 250 median

Median + Average: average the k central values.


10, 10, 20, 20, 25, 25, 30, 30, 250

24

Median vs Average Filtering

Salt & Pepper Noise

3 X 3 Average

5 X 5 Average

7 X 7 Average
7

Median

Salt & Pepper Noise

Neighborhood Averaging - Example

Salt & Pepper Noise

3 X 3 Average

5 X 5 Average

7 X 7 Average
9

Median

Multiple Median Filtering

Large Noise

Median

Median x 2

Median x 4

Median x 8

Median x 6

Median x 7

10

Median Filtering - Failure

Original

Salt & Pepper Noise

Median Filter

11

Oriented Median Filtering

Original

Salt & Pepper Noise

Median Filter

Oriented Median Filter

12

Oriented Filters
Salt & Pepper noise

4x4 Average

7x2 Average

13

Oriented Filtering - Example

Original

Noisy Image

4x4 Average

Oriented 6x2 Average

14

Median filtering
Denoising with LPF (averaging)

Original corrupted With salt & pepper noise

Denoising with median filter

15

Bilateral Filtering
Tomasi & Manduchi 98

In shift-invariant linear filters, neighboring pixels are weighted according to their spatial distance:

g ( x, y ) =

m , nS

w (m x, n y ) f (m, n)
s

In bilateral filtering the weights are determined according to the spatial and photometric distances:
g ( x, y ) =

m , nS

w (m x, n y ) w ( f ( x, y) f (m, n)) f (m, n )


s p

For example:

w (s, t ) = exp s 2 + t 2 /

( (

) )

16

Sharpening
A sharpening filter is applied in order to enhance edges and fine details (high frequency) in an image: Assume B=A*G is a smoothed image, where G is a smoothing mask. B*( - G) contains the fine details of the (smoothed) image.

B+B*( - G) = B*( (1+)-G)=B*S()


amplifies fine details in the image. The parameter controls the amount of amplification.
0 -1/6 0

0 1/6 0 G= 1/6 2/6 1/6 0 1/6 0 S(1) =

-1/6 10/6 -1/6 0 -1/6 0

17

18

Original

S(0.5)

S(1)

B*(-G)

19

S(1.2)

Gibbs phenomena in edge enhancement

-G

B*S

20

You might also like