5
1 Chapter 4: Image Filtering INEL 6088 Lecture Notes – Computer Vision Prof. M. Toledo - Fall 2004 9/21/2004 INEL 6088 Lecture Notes - Ch. 4 - Image Filtering 2 Histogram Modification (to improve contrast) Scaling: maps pixels in the range [a,b] to [z 1 ,z k ]. A pixel value z will have a new pixel value z’: 1 1 ) ( z z z z k a b a z + - = - - 9/21/2004 INEL 6088 Lecture Notes - Ch. 4 - Image Filtering 3 If the desired gray value distribution is known a priori: Original: p i pixels at z i Desired: q i pixels at z i Start from left select k 1 so = - = < 1 1 1 1 1 1 k i i k i i p q p = - = < + 2 2 1 2 1 1 1 k i i k i i p q q p Then find k 2 such that 9/21/2004 INEL 6088 Lecture Notes - Ch. 4 - Image Filtering 4 Systems Formalism Kernel or mask 9/21/2004 INEL 6088 Lecture Notes - Ch. 4 - Image Filtering 5 Characteristics of Convolution Linear (convolution o a sum is the sum of the convolutions) Convolution of a scaled image is the scaled convolution Spatially invariant Convolution in the image domain correspond to multiplication in the (spatial) frequency domain Frequency-domain convolution used only for very large kernels – not common in machine vision The kernel defines the filter being used We use non-linear filters as well; formalism does not apply but many are used in a very similar way. 9/21/2004 INEL 6088 Lecture Notes - Ch. 4 - Image Filtering 6 Noise-free Salt & pepper - Random black & white pixels Impulse - Only random white Gaussian – random gray level variations Common Types of Noise

Chapter 4: Image Filtering - Engineeringmtoledo/6088/2004/handout_ch4.pdf · • Convolution in the image domain correspond to multiplication in the (spatial) frequency domain •

  • Upload
    others

  • View
    43

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 4: Image Filtering - Engineeringmtoledo/6088/2004/handout_ch4.pdf · • Convolution in the image domain correspond to multiplication in the (spatial) frequency domain •

1

Chapter 4: Image Filtering

INEL 6088 Lecture Notes – Computer Vision

Prof. M. Toledo - Fall 2004

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

2

Histogram Modification (to improve contrast)

Scaling: maps pixels in the range [a,b] to [z1,zk].

A pixel value z will have a new pixel value z’:

11)( zzzz kabaz +−=′ −

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

3

If the desired gray value distribution is known a priori:

Original: pi pixels at ziDesired: qi pixels at zi

Start from left select k1so

��=

=

<≤11

11

1

1

k

ii

k

ii pqp

��=

=

<+≤22

121

1

1

k

ii

k

ii pqqp

Then find k2 such that

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

4

Systems Formalism

Kernel or mask

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

5

Characteristics of Convolution

• Linear (convolution o a sum is the sum of the convolutions)

• Convolution of a scaled image is the scaled convolution

• Spatially invariant

• Convolution in the image domain correspond to multiplication in the (spatial) frequency domain

• Frequency-domain convolution used only for very large kernels – not common in machine vision

• The kernel defines the filter being used

• We use non-linear filters as well; formalism does not apply but many are used in a very similar way.

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

6

Noise-free

Salt & pepper -Random black & white pixels

Impulse -Only random white

Gaussian –random gray level variations

Common Types of Noise

Page 2: Chapter 4: Image Filtering - Engineeringmtoledo/6088/2004/handout_ch4.pdf · • Convolution in the image domain correspond to multiplication in the (spatial) frequency domain •

2

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

7

Mean Filter

Smoothing filter: pixel weights are not equal, but are usually symmetric and add 1.

Single-peak, or main lope

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

8

3×3 5×5 7×7

Mean Filter Applied to Noisy Images

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

9

Result of using the smoothing filter seen previously

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

10

Median Filter

• Nonlinear• Very effective to remove salt & pepper and impulse!• Retain image detail

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

11

Results of Applying a Median Filter on Previous Noisy Images

3×3 5×5 7×79/21/2004 INEL 6088 Lecture Notes - Ch. 4 -

Image Filtering12

Gaussian Smoothing

22

22

],[ σji

ejig+−

=

Page 3: Chapter 4: Image Filtering - Engineeringmtoledo/6088/2004/handout_ch4.pdf · • Convolution in the image domain correspond to multiplication in the (spatial) frequency domain •

3

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

13

Properties of Gaussian Filter

• Rotational symmetry• Single lope in both space and frequency

domain• Smoothing is controlled by a single

parameter, �

• Separable• Will spread impulse and salt & pepper

noise!

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

14

Gaussian Mean

space

frequency

Multiple lopes can cause halos on image

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

15

• To generate the 1D kernel, we must discretize the gaussian• Require the mask width to subtend most of the gaussian area:

use w = 5�

for 98.76% of the area; for a

=0.6, use w = 3 pixels; for

=1, use w = 5

Gaussian filter – can be applied as the convolution of two 1D filters

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

16

• Use discrete kernel entries to reduce filtering times – normalize the smallest kernel entry to make it 1

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

17 9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

18

Fig 4.13 – Result of using a single horizontal convolution mask k on (a) original noisy image. (b) After convolution with k. (c) transpose of (b). (d) convolution of (c) with k. (e) Transpose of (d) to get the final smoothed image.

Page 4: Chapter 4: Image Filtering - Engineeringmtoledo/6088/2004/handout_ch4.pdf · • Convolution in the image domain correspond to multiplication in the (spatial) frequency domain •

4

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

19

Design of Gaussian Filters• Use the row n of Pascal’s Triangle as a one-

dimensional, n-point approximation of a Gaussian filter.

1615151561

15101051

14641

1331

121

11

1

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

20

Fig. 4-14: Using the fifth row of Pascal’s triangle as a Gaussian filter. (a) original; (b) After smoothing in the horizontal dir. (c) After smoothing in the vertical direction

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

21

Another approach: compute the mask directly from the discrete Gaussian distribution. Below it is shown the result of using

2

22

2],[ σji

cjig e

+−=

For n=7 and �2=2.

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

22

After multiplying by 91 so that the smallest values (corners) be 1,

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

23

Fig. 4-15: 3-D plot of the 7x7 Gaussian mask.

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

24

The result of the convolution must be divided by the sum of the mask weights (1115) to ensure that regions of uniform intensity are not affected.

Page 5: Chapter 4: Image Filtering - Engineeringmtoledo/6088/2004/handout_ch4.pdf · • Convolution in the image domain correspond to multiplication in the (spatial) frequency domain •

5

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

25

Fig. 4-16: Result of Gaussian smoothing using the 7x7 mask.

9/21/2004 INEL 6088 Lecture Notes - Ch. 4 -Image Filtering

26