SPATIAL FILTERING SPATIAL FILTERING Linear Filters Lowpass Filters

  • Slides: 46
Download presentation
SPATIAL FILTERING

SPATIAL FILTERING

SPATIAL FILTERING Linear Filters Lowpass Filters Highpass Filters Bandpass Filters Nonlinear Filters Median Filter

SPATIAL FILTERING Linear Filters Lowpass Filters Highpass Filters Bandpass Filters Nonlinear Filters Median Filter

LINEAR SPATIAL FILTERING Given a filter F and an image I, we can compute

LINEAR SPATIAL FILTERING Given a filter F and an image I, we can compute ^ ^ a filtered image, I , such that I(x, y) is a linear combination of I(x, y) and its neighbors.

LINEAR SPATIAL FILTERING f f f 1 4 7 f f 2 3 f

LINEAR SPATIAL FILTERING f f f 1 4 7 f f 2 3 f 5 6 f 8 i 1 i 2 i 3 i 4 i 5 i 6 i 7 i 8 i 9 9 ^ i 5= f 1* i + 1 f * i 2+ f 2* i +3 f *3 i + 4 f * i 4 + f *i 6 6 7 7 8 8 9 9 5 5

LINEAR SPATIAL FILTERING 0 -1 -1 0 4 -1 0 2 3 5 7

LINEAR SPATIAL FILTERING 0 -1 -1 0 4 -1 0 2 3 5 7 2 3 4 7 5 2 5 6 5 3 1 2 6 2 2 1 7 3 3 2 0

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 0 -1 0 3 4

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 0 -1 0 3 4 5 7 2 7 5 2 5 6 5 3 1 2 6 2 2 1 7 3 3 2 0

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 0 -1 0 3 4

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 0 -1 0 3 4 2 5 7 2 7 5 2 5 6 5 3 1 2 6 2 2 1 7 3 3 2 0

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 5 0 -1 0 3

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 5 0 -1 0 3 4 7 2 1 7 2 5 6 5 3 1 2 6 2 2 1 7 3 3 2 0

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 5 7 0 -1 0

LINEAR SPATIAL FILTERING 0 -1 4 -1 2 3 5 7 0 -1 0 3 4 7 5 2 1 3 2 2 5 6 5 3 1 2 6 2 2 1 7 3 3 2 0

LINEAR SPATIAL FILTERING 0 -1 2 1 3 16 0 2 3 3 4

LINEAR SPATIAL FILTERING 0 -1 2 1 3 16 0 2 3 3 4 -1 5 0 7 4 -1 7 2 -1 0 5 2 5 6 5 3 1 2 6 2 2 1 7 3 3 2 0

LINEAR SPATIAL FILTERING 0 -1 2 2 1 3 16 -1 3 5 7

LINEAR SPATIAL FILTERING 0 -1 2 2 1 3 16 -1 3 5 7 -1 2 0 4 -1 3 4 7 0 -1 5 2 5 6 5 3 1 2 6 2 2 1 7 3 3 2 0 0

LINEAR SPATIAL FILTERING 0 -1 2 1 1 0 2 3 -1 4 -1

LINEAR SPATIAL FILTERING 0 -1 2 1 1 0 2 3 -1 4 -1 3 4 0 -1 0 3 16 -1 5 6 5 7 2 7 5 2 5 3 1 2 6 2 2 1 7 3 3 2 0

LINEAR SPATIAL FILTERING 2 1 1 -3 3 16 -1 0 2 3 5

LINEAR SPATIAL FILTERING 2 1 1 -3 3 16 -1 0 2 3 5 -1 4 -1 3 4 7 0 -1 0 5 6 5 7 2 5 2 3 1 2 6 2 2 1 7 3 3 2 0

LOWPASS SPATIAL FILTERING (retains the low frequency components) • Used for image smoothing or

LOWPASS SPATIAL FILTERING (retains the low frequency components) • Used for image smoothing or blurring • Filter coefficients are often all positive • The sum of the coefficients (after scaling) is 1.

LOWPASS SPATIAL FILTERING 1 9 x 1 1 1 1 1 simple 3 x

LOWPASS SPATIAL FILTERING 1 9 x 1 1 1 1 1 simple 3 x 3 boxcar filter

LOWPASS SPATIAL FILTERING 1 25 x 1 1 1 1 1 1 1 simple

LOWPASS SPATIAL FILTERING 1 25 x 1 1 1 1 1 1 1 simple 5 x 5 boxcar filter

LOWPASS SPATIAL FILTERING 1 16 x 1 2 4 2 1 3 x 3

LOWPASS SPATIAL FILTERING 1 16 x 1 2 4 2 1 3 x 3 weighted average filter

HIGHPASS SPATIAL FILTERING (retains the high frequency components - edges) • Used for edge

HIGHPASS SPATIAL FILTERING (retains the high frequency components - edges) • Used for edge detection and enhancement • Filter coefficients are positive and negative • The sum of the coefficients is 0 • Also know as derivative filters

HIGHPASS SPATIAL FILTERING -1 -1 8 -1 -1

HIGHPASS SPATIAL FILTERING -1 -1 8 -1 -1

HIGHPASS SPATIAL FILTERING 0 -1 4 -1 0

HIGHPASS SPATIAL FILTERING 0 -1 4 -1 0

HIGHPASS SPATIAL FILTERING 1 0 0 1 0 -1 -1 0 Roberts Operators

HIGHPASS SPATIAL FILTERING 1 0 0 1 0 -1 -1 0 Roberts Operators

HIGHPASS SPATIAL FILTERING -1 -1 0 1 0 0 0 -1 0 1 1

HIGHPASS SPATIAL FILTERING -1 -1 0 1 0 0 0 -1 0 1 1 -1 0 1 Prewitt Operators

Prewitt Operators

Prewitt Operators

HIGHPASS SPATIAL FILTERING -1 -2 -1 -1 0 0 0 -2 0 2 1

HIGHPASS SPATIAL FILTERING -1 -2 -1 -1 0 0 0 -2 0 2 1 -1 0 1 Sobel Operators

Sobel Operators

Sobel Operators

Sobel - horizontal Sobel - vertical Sobel - horizontal + vertical

Sobel - horizontal Sobel - vertical Sobel - horizontal + vertical

Sobel - horizontal Sobel - vertical Value is normalized and scaled to 255 new

Sobel - horizontal Sobel - vertical Value is normalized and scaled to 255 new = 255 * (val - min)/(max-min) Sobel - horizontal + vertical

Signed highpass results Absolute value highpass results new = 255 * (val - min)/(max-min)

Signed highpass results Absolute value highpass results new = 255 * (val - min)/(max-min) new = abs(val) result is contrast stretched

HIGHPASS = ORIGINAL - LOWPASS

HIGHPASS = ORIGINAL - LOWPASS

HIGHPASS = ORIGINAL - LOWPASS -1 -1 8 -1 -1 1 x 9 1

HIGHPASS = ORIGINAL - LOWPASS -1 -1 8 -1 -1 1 x 9 1 1 1 1 1 ^ i 5= f 1* i + 1 f * i 2+ f 2* i +3 f *3 i + 4 f * i 4 + f *i 6 6 7 7 8 8 9 9 5 5

HIGHPASS = ORIGINAL - LOWPASS 0 0 0 0 1 x 9 1 1

HIGHPASS = ORIGINAL - LOWPASS 0 0 0 0 1 x 9 1 1 1 1 1 ^ i 5= f 1* i + 1 f * i 2+ f 2* i +3 f *3 i + 4 f * i 4 + f *i 6 6 7 7 8 8 9 9 5 5

HIGHPASS = ORIGINAL - LOWPASS ^ i 5= 0 * i + 10 *

HIGHPASS = ORIGINAL - LOWPASS ^ i 5= 0 * i + 10 * i + 02* i + 0 *3 i + 1 * i 4 + 0*i 6 ^ i 5= 8 9 1 (1 9 * i + 11 * i + 1 2* i + 1 *3 i + 1 * i 4+ 1*i ) 6 ^ i 5= 7 5 1 (i 9 7 8 5 9 +1 i + 2 i + i 3 + i 4+ i + 5 i + 6 i + i 7) 8 9

ORIGINAL - SMOOTHED

ORIGINAL - SMOOTHED

ORIGINAL - = HIGHPASS SMOOTHED

ORIGINAL - = HIGHPASS SMOOTHED

HIGHBOOST = (A - 1)(ORIGINAL) + HIGHPASS

HIGHBOOST = (A - 1)(ORIGINAL) + HIGHPASS

HIGHBOOST = (A - 1)(ORIGINAL) + HIGHPASS if A = 1, HIGHBOOST = HIGHPASS

HIGHBOOST = (A - 1)(ORIGINAL) + HIGHPASS if A = 1, HIGHBOOST = HIGHPASS if A > 1, part of the original is added to the HIGHPASS filtered image Also called unsharp masking

ORIGINAL + HIGHPASS

ORIGINAL + HIGHPASS

ORIGINAL HIGH BOOST + HIGHPASS

ORIGINAL HIGH BOOST + HIGHPASS

NONLINEAR SPATIAL FILTERING f 1 f 2 f 3 f 4 f 5 f

NONLINEAR SPATIAL FILTERING f 1 f 2 f 3 f 4 f 5 f 6 f 7 f 8 f 9 Median Filter Computes median pixel value within a neighborhood

Noisy Image

Noisy Image

Noisy Image Result of 3 x 3 average

Noisy Image Result of 3 x 3 average

Noisy Image Result of 3 x 3 median

Noisy Image Result of 3 x 3 median

Noisy Image Result of 3 x 3 median (2 passes)

Noisy Image Result of 3 x 3 median (2 passes)