Convolution

Preview:

DESCRIPTION

Basis beeldverwerking (8D040 ) d r. Andrea Fuster Prof.dr . Bart ter Haar Romeny dr. Anna Vilanova Prof.dr.ir . Marcel Breeuwer. Convolution. Contents. Spatial filtering Correlation Convolution Filters: Smoothing filters Sharpening filters Borders. Spatial filtering. - PowerPoint PPT Presentation

Citation preview

Basis beeldverwerking (8D040)

dr. Andrea FusterProf.dr. Bart ter Haar Romenydr. Anna VilanovaProf.dr.ir. Marcel Breeuwer

Convolution

Contents

2

• Spatial filtering• Correlation• Convolution• Filters:

• Smoothing filters• Sharpening filters

• Borders

Basis beeldverwerking 8D040

Spatial filtering

• Input image , use a filter to obtain processed image

• Filter consists of• Neighbourhood (rectangular)• Mostly odd dimensions• Predefined operation

• Create new pixel value in center of neighbourhood

3Basis beeldverwerking 8D040

Spatial filtering

• Filter operation

• More compact notation - filter

4Basis beeldverwerking 8D040

Intuition to filtering

5Basis beeldverwerking 8D040

Move filter over image

6Basis beeldverwerking 8D040

7Basis beeldverwerking 8D040

8Basis beeldverwerking 8D040

9Basis beeldverwerking 8D040

10Basis beeldverwerking 8D040

Correlation

• While moving the filter, at each position

• Multiply values of overlapping locations• Sum all multiplication results

11Basis beeldverwerking 8D040

Correlation vs. Convolution

• Discrete Correlation 2D

• Discrete Convolution 2D

12Basis beeldverwerking 8D040

- Equivalent to first rotate the filter 180 degrees and correlate-

Correlation vs. Convolution

• With convolution, first mirror the filter kernel with respect to its origin.

• With correlation, do not mirror the filter kernel with respect to its origin.

13

convolution correlation

Basis beeldverwerking 8D040

Example

See blackboard ☺ (or figure 3.30 Gonzalez and Woods)

Basis beeldverwerking 8D040 14

Convolution – 1D cont. case

• Imagine a system with • input signal• transfer function• output signal

• then

15Basis beeldverwerking 8D040

Definition

16

output input

system transfer function

Basis beeldverwerking 8D040

Dirac delta function (unit impulse)

• Definition

• Constraint

• Sifting property

• Specifically for t=0

17Basis beeldverwerking 8D040

Convolution

• Let

18Basis beeldverwerking 8D040

We saw this already in the discrete case

Properties of convolution

• Commutative

• Associative

• Distributive19Basis beeldverwerking 8D040

Convolution is commutative• Proof

• Let

• Q.E.D.

20Basis beeldverwerking 8D040

Convolution is associative - 1

• Proof

21Basis beeldverwerking 8D040

Convolution is associative - 2

22Basis beeldverwerking 8D040

Convolution is associative - 3

• Let

23Basis beeldverwerking 8D040

Convolution is associative - 4

• Q.E.D.

24Basis beeldverwerking 8D040

Convolution is distributive - 1

• Proof

25Basis beeldverwerking 8D040

Convolution is distributive - 2

• Q.E.D.

26Basis beeldverwerking 8D040

Discrete convolution

• 1D

• 2D

27Basis beeldverwerking 8D040

Discrete convolution

• Formulas take summation from to• Filters have a limited size, e.g.,

• 1D 2a + 1

• 2D (2a + 1, 2b + 1)

28Basis beeldverwerking 8D040

Filter Kernels

29

Kernel

Basis beeldverwerking 8D040

Filters

• Idea: correlate or convolve image with different filters in order to obtain different results, i.e., processed images

Basis beeldverwerking 8D040 30

Smoothing filters

• Average intensities – result is blurred image, less details

• Response: (z’s image intensities)

31Basis beeldverwerking 8D040

… NxN filter

Smoothing filters

• Note that:

− Sum of filter coefficients is 1 (normalized filter)− Correlation = convolution (symmetric filter)− Filter size effect?

Basis beeldverwerking 8D040 32

Smoothing filters - example

33Basis beeldverwerking 8D040

Original 3x3 smoothing filter NxN filter (see figure 3.33 in

Gonzalez and Woods!)

Effect of normalized smoothing kernel

Basis beeldverwerking 8D040 34

normalized

non- normalized

Sharpening filters

• Enhance parts of the image where intensities change rapidly, such as edges • Basic derivative filters

• Measure change of intensity in x or y direction

35Basis beeldverwerking 8D040

Example

36Basis beeldverwerking 8D040

Arbitrary angle derivative

• Given and

37Basis beeldverwerking 8D040

Arbitrary angle derivative

38Basis beeldverwerking 8D040

Prewitt gradient kernel

• Derivative in one direction, smoothing in the perpendicular direction

39Basis beeldverwerking 8D040

Example

40Basis beeldverwerking 8D040 25-03-2009

Prewitt

Basic derivative

Sobel kernel

41Basis beeldverwerking 8D040

Example

42

(Thanks to Wikipedia☺)

Derivative filters

• Note that coefficients in all of the previous filters sum to zero, i.e., zero response in area of constant intensity

• Also: gradient, Laplacian, …

Basis beeldverwerking 8D040 43

Borders

• Do you see any problems at image borders?

• Try position (0,0)

44Basis beeldverwerking 8D040

Border problems

• How to handle?• No border handling

• Border is not filtered• Padding

• Put values outside image border • Cyclic padding

• Use values from the other side of the image

45Basis beeldverwerking 8D040

Zero padding

46Basis beeldverwerking 8D040

Cyclic padding

47Basis beeldverwerking 8D040

Padding

• Remember: padding is artificial!• The values chosen outside the border influence the

outcome image

48Basis beeldverwerking 8D040

End of part 2

Thanks and see you Wednesday 16!

Basis beeldverwerking 8D040 49