Filtering (II) Dr. Chang Shu COMP 4900C Winter 2008.

Post on 19-Jan-2018

213 views 0 download

description

Linear Filtering – convolution Image Kernel = 5 Filter Output The output is the linear combination of the neighbourhood pixels The coefficients come from a constant matrix A, called kernel. This process, denoted by ‘*’, is called (discrete) convolution.

Transcript of Filtering (II) Dr. Chang Shu COMP 4900C Winter 2008.

Filtering (II)

Dr. Chang Shu

COMP 4900CWinter 2008

Image FilteringModifying the pixels in an image based on some

functions of a local neighbourhood of the pixels

10 30 10

20 11 20

11 9 1

pN(p)

5.7 pf

Linear Filtering – convolution

1 3 0

2 10 2

4 1 1

Image

1 0 -1

1 0.1 -1

1 0 -1

Kernel

= 5

Filter Output

The output is the linear combination of the neighbourhood pixels

2/

2/

2/

2/

),(),(*),(m

mk

m

mhA kjhiIkhAAIjiI

The coefficients come from a constant matrix A, called kernel.This process, denoted by ‘*’, is called (discrete) convolution.

Handle Border Pixels

• Set the value of all non-included pixels to zero.

• Set all non-included pixels to the value of the corresponding pixel in the input image.

Near the borders of the image, some pixels do not have enoughneighbours. Two possible solutions are:

Smoothing by Averaging

1 1 1

1 1 1

1 1 191*

Convolution can be understood as weighted averaging.

Gaussian Filter

2

22

2 2exp

21,

yxyxG

array mman ofelement an is , where khG

2

22

222

1),(

kh

ekhG

Discrete Gaussian kernel:

Gaussian Filter

*

1

Gaussian Kernel is Separable

2/

2/

22/

2/

2

2/

2/

2/

2/

2

2/

2/

2/

2/

),(

),(

),(),(

2

2

2

2

2

22

m

mk

km

mh

h

m

mh

m

mk

kh

m

mh

m

mk

G

kjhiIee

kjhiIe

kjhiIkhG

GII

2

2

2

2

2

22

222 khkh

eee

since

Gaussian Kernel is SeparableConvolving rows and then columns with a 1-D Gaussian kernel.

1 9 18 9 1

1

9189

1

381

=I Ir

Ir 381

= result

The complexity increases linearly with instead of with .m 2m

Gaussian vs. Average

Gaussian Smoothing Smoothing by Averaging

Noise Filtering

Gaussian Noise

After Gaussian Smoothing

After Averaging

Noise Filtering

Salt-and-pepper noise

After Gaussian smoothing

After averaging

Nonlinear Filtering – median filter

Replace each pixel value I(i, j) with the median of the valuesfound in a local neighbourhood of (i, j).

Median Filter

Salt-and-pepper noise After median filtering

Salt-and-Pepper Noise Removal by Median-type Noise Detectors and Edge-preserving Regularization Raymond H. Chan, Chung-Wa Ho, and Mila NikolovaIEEE Transactions on Image Processing, 14 (2005), 1479-1485.