Image Filtering

17
Image Filtering Purpose: Image Enhancement Noise Removal Edge Enhancement/Detection

description

Linear Algebra

Transcript of Image Filtering

Page 1: Image Filtering

Image Filtering

Purpose:

–Image Enhancement

–Noise Removal

–Edge Enhancement/Detection

Page 2: Image Filtering

• An image is a matrix of points called pixels

• Resolution

– 640 X 480 ( 0.3 MegaPixels)

– 1600 X 1200 ( 2 MegaPixels)

– 3872 X 2592 (10 MegaPixels)

• Grayscale: generally 8 bits per pixel Intensities in range

[0…255]

• RGB color: 3 of 8-bit color planes: IR , IG , IB

Images

Page 3: Image Filtering

Example of a grayscale image intensity I(x,y)

(0 = black, 255 = white)

255 255 255 255 255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255 255 255 255 255

255 255 255 20 0 255 255 255 255 255 255 255

255 255 255 75 75 75 255 255 255 255 255 255

255 255 75 95 95 75 255 255 255 255 255 255

255 255 96 127 145 175 255 255 255 255 255 255

255 255 127 145 175 175 175 255 255 255 255 255

255 255 127 145 200 200 175 175 95 255 255 255

255 255 127 145 200 200 175 175 95 47 255 255

255 255 127 145 145 175 127 127 95 47 255 255

255 255 74 127 127 127 95 95 95 47 255 255

255 255 255 74 74 74 74 74 74 255 255 255

255 255 255 255 255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255 255 255 255 255

Images

=

x

y

Page 4: Image Filtering

r s t

u v w

x y z

Origin x

y Image I (x, y)

eprocessed = v*e + r*a + s*b + t*c + u*d + w*f + x*g + y*h + z*i

Filter Simple 3*3

Neighbourhood e

3*3 Filter

a b c

d e f

g h i

Original Image

Pixels

*

This process is called convolution and is repeated for every pixel in the original image to get the filtered image

Image Spatial Filtering

Page 5: Image Filtering

Simply average all of the pixels in a neighbourhood around a central value

1/9 1/9 1/9

1/9 1/9

1/9

1/9 1/9

1/9

Mean Smoothing Filters

sum of filter values = 1

Page 6: Image Filtering

Example

8 5 8 8 5 8

8 5 8 8 5 8

8 5 8 8 5 8

1

9

1 1 1

1 1 1

1 1 1

7 7 7 7 7 7

7 7 7 7 7 7

7 7 7 7 7 7

Mean Smoothing Filters

Page 7: Image Filtering

Image smoothed with mean filters

Original 33 99

Mean Smoothing Filters

Page 8: Image Filtering

Pixels closer to the central pixel are more important

1/16 2/16

1/16

2/16 4/16

2/16

1/16 2/16

1/16

Gaussian Weighted Filter

Weighted Smoothing Filters

sum of filter values = 1

Page 9: Image Filtering

Gaussian

Original image

Mean

Weighted Smoothing Filters

Page 10: Image Filtering

Example

6 7

3 7 8

2 3

4 6 7

2, 3, 3, 4, 6, 7, 7, 7, 8

Median Smoothing Filters

Page 11: Image Filtering

Noisy image 5x5 median filter 5x5 mean filter

Median Smoothing Filters

Page 12: Image Filtering

1 1 1 1 1 1 1 1 1

0 0 0 0 2 0 0 0 0

-

Edge Enhancement (Sharpening)

sum of filter values = 1

Page 13: Image Filtering

• Convert a 2D image into a set of curves

• Extracts salient features of the scene

Edge Detection

Page 14: Image Filtering

• Directional Edge Detection

• Simple mask for:

– horizontal edges

– vertical edges

-1 1

-1

1

Edge Detection

sum of filter values = 0

Page 15: Image Filtering

Sobel Filter is a combination of 2 filters:

the combined image will show edges from both directions

-1 0 1

-2 0 2

-1 0 1

-1 -2 -1

0 0 0

1 2 1

Sobel Edge Detection

xI yI

2 2

x yI I

Page 16: Image Filtering

Sobel Edge Detection

xI yI 2 2

x yI I

Page 17: Image Filtering

x

y Image I(x, y)

e

At the borders of an image we are missing pixels to form a neighbourhood

• Truncate the image

• Replicate border pixels

• Pad the image (with either

all white or all black pixels)

Dealing with Borders