Course 2 Image Filtering. Image filtering is often required prior any other vision processes to...

30
Course 2 Image Filtering

Transcript of Course 2 Image Filtering. Image filtering is often required prior any other vision processes to...

Course 2 Image Filtering

Course 2 Image Filtering

Image filtering is often required prior any other vision processes to remove image noise, overcome image corruption and change distribution in an image.

——linear filter

——nonlinear filter

1. Linear system

delta function impulse response

  Continuous case:

Discrete case:

),( 00 yyxx Linear Space

Invariant System

),( 00 yyxxh

othersyyxxyyxx ,0

,,),( 0000

othersjjiijjii ,0

,,1),( 0000

1),(),(),(

),(),(),(

0000

0000

0

_0

0

0

dxdyyyxxdxdyyyxxyx

yxfdxdyyyxxyxf

y

y

x

x

LSI h(x, y)

input

f (x, y)

output

g(x, y)

ydxdyyxxhyxf

yxhyxfyxg

),(),(

),(),(),( —— convolution ( 卷积 )

For discrete case:

In Fourier domain:

 

then:

, ( , ) ,

, , ;1 1

g i j f i j h i j

N Mf k l h i k j l

k l

),(),(

),(),(

),(),(

vuGyxg

vuHyxh

vuFyxf

),(),(),( vuHvuFvuG

( , )

1( , ) , ;

k l N

g i j f k lM

2. Mean Filter

—— average intensity values of the neighbor pixels at a pixel.

e.g. window neighbors.

where

9133

11

1 1

1( , ) , ;

9

ji

k i l j

g i j f k l

9M 91, jih

1 1 1

1 1 1

1 1 1

The larger window size, the efficient in reducing noise, but the more blurring original image (lose image details)—— you must make a trade-off !

To reduce windows boundary effect and for a smooth filtering, filter elements are often weighted.

  16

1

8

1

4

1

16

1

16

1

16

1

8

1

8

1

8

1

Mean Filter on Gaussian noise corrupted image

3. Gaussian Filter:

impulse response of Gaussian filter:

—— linear system

—— rotational symmetric

—— Fourier Transformation is still a Gaussian

2

2

2

22

22),( ryx

eeyxh

For 1-D case:

It is still a Gaussian!

2

2

2 2

2 2

2

2

2

2

2

2 2

2

2

22

( ) ( )

cos sin

cos

2

1

j x

xj x

x x

x

F h x h x e dx

e e dx

e xdx j e xdx

e xdx

e

where

——Separatibility

It can easily be seen hat the Gaussian core can be separated in both space domain and Fourier domain, i.e.

So,

]},[{

],[

],[],[],[],[

1

22

2

1

22

2

1 1

22

)22(

1 1

ljkifee

ljkife

ljkiflkhjifjih

n

l

lm

k

k

m

k

n

l

lk

m

k

n

l

]),[][(][],[ 21 jifjhihjig

In Fourier Domain,

——Cascading operation:

Let

If a Gaussian filter has a large parameter , it requires a large operation mask and thus, it will take long time to process.

),(),( vuHyxh

)(),()(),(),(),( 21 vHvuFuHvuHvuFvuG

22

2

21 )()(

x

exhxh

2)2(2

2

22

2)(22

2

21 )()()(

xx

edeexhxhxh

We can separate the large Gaussian of into two smaller Gaussian filters of parameter and perform the filtering processes in cascade.

4. Discrete Guassian Filter

Where

window size

22

;],[22

22

ji

kejih

1 12 2

2 2

1 ( , ), ( )

N N

N Ni j

k h i j normalizing factor

NN

To form a Gaussian Filter:

(1) Choose a proper size N of mask window.

(2) Calculate the value of each mask element.

 e.g.

(3)  Scale all mask elements to integer with the same scaling factor.

7,22 N

011.0011.0

779.0

779.01779.0

779.0

011.0011.0

91011.01 Scale

(4) find the normalizing factor k

Therefore, for an input image output of Gaussian smooth is:

11

71

719171

71

11

1115

1

11

71

719171

71

11

]);,[,(1115

1),( jihjifjig

),,( jif

By the way,

A two-dimenssional Gaussian filter can be extended by two one –dimentional Gaussian

(how? Homework).

5. Median Filter (nonlinear)

------ Very efficient to remove salt-and–pepper noise.

(1)In a window of of filter mask, order the intensity value of points.

set

(2) Set the image pixel with intensity

NN

1I 2I NI

2NI

… … … …

… … … …

… … …

2321 NIIII

},,,,{ 2321 NIIIIA

}{0 AmedianI

75 99 36

38 49 10

19 98 22

For example,

99,98,75,49,38,36,22,19,10A

380 AmedianI

Other nonlinear filters:

——minimum filter(remove salt noise):

——maximum filter (remove pepper noise)

——Midpoint filter ( remove Gaussian noise and uniform noise)

0 min I A

0 maxI A

210 2

NI I

I

Median filter on salt-and-pepper noise corrupted image

Minimum filter on salt noise corrupted image

Morphological Filters

(1)Review of “set”:

Intersection:

Union:

Complement:

Translation:

where are position, and is a vector operation.

A B P P A and P B

A B P P A or P B

}|{ APandPPA

AabaAb ba, ba

A B

(2) Dilation:

given an image

and structuring element

dilatation of A by B is defined as

Dilatation operation tends to inflate the original image.

maaaA ,,, 21

mbbbB ,,, 21

Bib

ibABA

(3) Erosion:

Erosion of A by B is defined by all pixel that

makes inside the image A, i.e.

or, equivalently

Erosion operation intends to shrink original

image.

Aa

aB

aA B a B A

BABA Θ

(4)Opening:

Open operation to an image is erosion followed by dilation with the same structuring element. It will remove the image regions that a too small to contain the structuring element, leaving the resulted image approximately unchanged.

(5)Closing:

Closing operation to an image is dilation followed by erosion. It will fill in holes and concavities smaller than structuring element, leaving the resulted image approximately unchanged.

BBA }{

BBA }{

6.Histogram Modification (Image Enhancement)

Uniform intensity distribution of an image can fit human interpretation of the image, it also meets the requirements of some image operations, such as image thresholding.

original intensity distribution uniform intensity distribution

Let original image has intensity and with probability . The transformed image has intensity

with probability .

Then, the transformation

]1,0[r)(rPr

]1,0[S )(sPs

r

r dPrTS 0 )()( 10 r

will makes resultant image have uniform intensity distribution, i.e.

Prove:

For discrete case, let the original image has intensity is the number of

1)( sPs

dPSr

r )(0

dr

dsPr

11)(

1)()(

)()()( 111 sTrsTrr

rsTrrs rPrP

ds

drPsP

1 2 3, , , , ,kZ Z Z ZiP

pixels at level in its histogram , we

want to map the image to a new one with the same

of number of intensity level but different histogram,

where the histogram is pre-

designed (e.g., uniform):

1) find a intensity level K, which that:

then, map pixels of levels to level in the new image.

iZnPPP ,,, 21

],,,[ 21 ki qqqq

1

11

11

1

K

ii

K

ii PqP

121 ,,, kZZZ

2) find intensity :

then, map pixels of level to level in new image.

3) repeat until all intensity levels of original image

have been included.

 

2

121

12

1

K

ii

K

ii PqqP

121,, kk ZZ

2Z

Original image

Enhanced image