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

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

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.

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

Filtering (II)

Dr. Chang Shu

COMP 4900CWinter 2008

Page 2: Filtering (II) Dr. Chang Shu COMP 4900C Winter 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

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

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.

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

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:

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

Smoothing by Averaging

1 1 1

1 1 1

1 1 191*

Convolution can be understood as weighted averaging.

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

Gaussian Filter

2

22

2 2exp

21,

yxyxG

array mman ofelement an is , where khG

2

22

222

1),(

kh

ekhG

Discrete Gaussian kernel:

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

Gaussian Filter

*

1

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

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

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

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

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

Gaussian vs. Average

Gaussian Smoothing Smoothing by Averaging

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

Noise Filtering

Gaussian Noise

After Gaussian Smoothing

After Averaging

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

Noise Filtering

Salt-and-pepper noise

After Gaussian smoothing

After averaging

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

Nonlinear Filtering – median filter

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

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

Median Filter

Salt-and-pepper noise After median filtering

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

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.