You are on page 1of 17

Image Filtering

Purpose:
Image Enhancement
Noise Removal
Edge Enhancement/Detection

Images
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
[0255]
RGB color: 3 of 8-bit color planes: IR , IG , IB

Images
Example of a grayscale image intensity I(x,y)
x
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

47 255 255

74 127 127 127

255 255 255

(0 = black, 255 = white)

74

74

74

95

95

95

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

Image Spatial Filtering


Origin

Simple 3*3
Neighbourhood

Original Image
Pixels

e
3*3 Filter

Image I (x, y)

Filter

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

This process is called convolution and is repeated for every


pixel in the original image to get the filtered image

Mean Smoothing Filters


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

1/

1/

1/

1/

1/

1/

1/

1/

sum of filter values = 1

Mean Smoothing Filters


Example



1 1 1 7 7 7 7 7 7
8 5 8 8 5 8
1

8 5 8 8 5 8
1
1
1
7 7 7 7 7 7

9
1 1 1 7 7 7 7 7 7
8 5 8 8 5 8

Mean Smoothing Filters


Image smoothed with mean filters

Original

33

99

Weighted Smoothing Filters


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


sum of filter values = 1

Weighted Smoothing Filters

Original
image

Mean

Gaussian

Median Smoothing Filters


Example

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

Median Smoothing Filters

Noisy image

5x5 mean filter

5x5 median filter

Edge Enhancement (Sharpening)

0 0 0
0 2 0
0 0 0

1 1 1
1 1 1
1 1 1

sum of filter values = 1

Edge Detection

Convert a 2D image into a set of curves


Extracts salient features of the scene

Edge Detection
Directional Edge Detection
Simple mask for:
horizontal edges

-1

vertical edges
-1
1

sum of filter values = 0

Sobel Edge Detection


Sobel Filter is a combination of 2 filters:
-1
-2
-1

0
0
0

1
2
1

-1
0
1

-2
0
2

-1
0
1

Iy

Ix

the combined image will show edges from


both directions
I x2 I y2

Sobel Edge Detection

Ix

Iy

I x2 I y2

Dealing with Borders


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

Truncate the image

Replicate border pixels


Pad the image (with either

all white or all black pixels)

Image I(x, y)

You might also like