60-520 Presentation Image Filters Student: Xiaoliu Chen Instructor: Dr. I. Ahmad School of Computer Science University of Windsor November 2003 Outline Introduction Spatial Filtering – Smoothing – Sharpening Frequency-Domain Filtering – Low pass – High pass Summary Image Filters 2 Introduction Filtering is the process of replacing a pixel with a value based on some operations or functions. The operations/functions used on the original image are called filters. – or masks, kernels, templates, windows… Image Filters 3 Introduction In digital image processing, filters are usually used to – suppress the high frequencies in an image • i.e., smoothing the image – suppress the low frequencies in an image • i.e., enhancing or detecting edges in the image Image Filters 4 Introduction Image filters fall into two categories: – Spatial domain • Filters are based on direct manipulation of pixels on an image plane. – Frequency domain • Filters are based on modifying the Fourier transform (FT) of an image. Image Filters 5 Spatial Filters The general processes can be denoted by the expression: g ( x, y ) T [ f ( x, y )] – f(x,y) is the input image – g(x,y) is the processed image – T is an operator on f, defined over some neighborhood of (x,y) Image Filters 6 Spatial Filters The principal approach in defining a neighborhood about a point (x,y) – use a subimage area centered at (x,y) – shapes of the neighborhood • circle • square • rectangular Image Filters 7 Spatial Filters Example: 3×3 neighborhood about a point (x,y) in an image x (x,y) (x-1,y-1) (x-1,y) (x,y-1) (x+1,y-1) (x,y) (x+1,y) Image f(x,y) (x-1,y+1) (x,y+1) (x+1,y+1) y Image Filters 8 x w(-1,-1) w(0,-1) w(1,-1) w(-1,0) w(0,0) w(1,0) w(-1,1) w(0,1) w(1,1) Mask Image f(x,y) y f(x-1,y-1) f(x-1,y) f(x,y-1) f(x+1,y-1) f(x,y) Mask coefficients f(x+1,y) f(x-1,y+1) f(x,y+1) f(x+1,y+1) Image Filters Pixels under mask 9 Spatial Filters – linear filters For linear spatial filtering, the result, R, at a point (x,y) is R=w(-1,-1)f(x-1,y-1) + w(0,-1)f(x,y-1) + …+ w(0,0)f(x,y) +… + w(0,1)f(x,y+1) + w(1,1)f(x+1,y+1) Image Filters 10 Spatial Filters – convolution In general, linear filtering of an image is given by the expression: g ( x, y ) a b w(s, t ) f ( x s, y t ) s at b – The image f is of size M×N – The filter mask is of size m×n m=2a+1, n=2b+1 Image Filters 11 Spatial Filters – smoothing Smoothing filters are used for blurring and for noise reduction. Smoothing, linear spatial filter – average filters – reduce “sharp” transitions – side effect Image Filters 12 Spatial Filters – smoothing, linear 1 1 1 Mean filters – example: 1 9 Gaussian noise Original 1 1 1 1 1 1 Image Filters 5×5 3×3 mean mean filter filter 13 Spatial Filters – smoothing, linear 1 1 1 Mean filters – example: 1 9 Salt and pepper 1 1 1 1 1 1 Image Filters 5×5 3×3 mean filter 14 Spatial Filters – smoothing, linear Weighted average filters 1 2 1 1 16 – example: 1 2 1 – general expression: a g ( x, y ) 2 4 2 b w(s, t ) f ( x s, y t ) s at b a b w(s, t ) s at b Image Filters 15 Spatial Filters – smoothing, nonlinear Order-statistic filters – nonlinear spatial filters – order/rank the pixels contained in the image area encompassed by the filter Image Filters 16 Spatial Filters – smoothing, nonlinear Median filters – replace a pixel value with the median of its neighboring pixel values – example: 23 25 26 30 40 Neighborhood values: 15, 19, 20, 23, 24, 25, 26, 27, 50 22 24 26 27 35 Median value: 24 11 16 10 20 30 18 20 50 25 34 19 15 19 23 33 Image Filters 17 Spatial Filters – smoothing, nonlinear Median filters – have excellent noise-reduction capabilities V.S. Gaussian noise removed Gaussian noise removedImage Filters By 3×3 median filter by 3×3 mean filter 18 Spatial Filters – smoothing, nonlinear Median filters – are particularly effective in salt & pepper V.S. Salt & pepper removed Salt & pepper removedImage Filters By 3×3 median filter by 3×3 mean filter 19 Spatial Filters – smoothing, nonlinear Max filters – maximum of neighboring pixel values – useful for finding the brightest points in an image Min filters – minimum of neighboring pixel values – useful for finding the darkest points in an image Image Filters 20 Spatial Filters – sharpening Principal objective – highlight fine detail in an image – enhance detail that has been blurred Sharpening can be accomplished by spatial differentiation Image Filters 21 Spatial Filters – sharpening For one dimensional function f(x) – first order derivative f f ( x 1) f ( x) x – second order derivative 2 f f ( x 1) f ( x 1) 2 f ( x) 2 x Image Filters 22 Spatial Filters – sharpening – A sample (a) (b) 5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7 (c) -1 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0 (d) -1 0 0 0 0 1 0 6 -12 (a) a scan line (c) first derivative 6 0 0 1 1 -4 1 1 0 0 7 -7 0 0 (b) image strip (d) second derivative Image Filters 23 Spatial Filters – sharpening The Laplacian – second derivative of a two dimensional function f(x,y) 2 2 f f 2 f 2 2 x y = [f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)] -4f(x,y) Image Filters 24 Spatial Filters – sharpening The Laplacian – use a convolution mask to approximate 0 1 0 1 1 1 -1 2 -1 1 -4 1 1 -8 1 2 -4 2 0 1 0 1 1 1 -1 2 -1 Image Filters 25 Spatial Filters – sharpening The Laplacian – example: Image Filters 26 Spatial Filters – sharpening The Laplacian – example: Image Filters 27 Frequency Filters – Fourier transform Fourier transform (FT) – decompose an image into its sine and cosine components – transform real space images into Fourier or frequency space images – In a frequency space image, each point represents a particular frequency contained in the real domain image. Image Filters 28 Frequency Filters – Fourier transform Discrete Fourier transform (DFT) 1 F (u, v) MN M 1 N 1 f ( x, y)e j 2 (ux / M vy / N ) x 0 y 0 Inverse DFT f ( x, y ) M 1 N 1 j 2 ( ux / M vy / N ) F ( u , v ) e u 0 v 0 Image Filters 29 Frequency Filters – Fourier transform – example: FT (log) Image Filters 30 Frequency Filters Basic steps for filtering in the frequency domain Filter function DFT f(x,y) Input image F(u,v) Inverse DFT H(u,v)F(u,v) g(x,y) Processed image Image Filters 31 Frequency Filters Frequencies in an image correspond to the rate of change in pixel values – High frequencies • rapid changes of gray level values – Low frequencies • slow changes of gray level values Image Filters 32 Frequency Filters Lowpass filters – attenuate high frequencies while “passing” low frequencies Highpass filters – attenuate low frequencies while “passing” high frequencies Image Filters 33 Frequency Filters – lowpass filters Ideal lowpass filters (ILPF) 1 if D(u, v) D0 H (u, v) 0 if D(u, v) D0 Image Filters 34 Frequency Filters – lowpass filters Butterworth lowpass filters (BLPF) 1 H (u, v) 1 [ D(u, v) / D0 ]2 n Image Filters 35 Frequency Filters – lowpass filters Gaussian lowpass filters (GLPF) H (u, v) e D2 (u ,v ) / 2 2 Image Filters 36 Frequency Filters – highpass filters Highpass filters H hp (u, v) 1 H lp (u, v) – Ideal higpass filters (IHPF) – Butterworth highpass filters (BHPF) – Gaussian highpass filters (GHPF) Image Filters 37 Image Filters 38 Frequency Filters – bandpass filters Bandpass filters – attenuate very low frequencies and very high frequencies – H bp H hp (u , v) H lp (u , v) – enhance edges while reducing the noise at the same time Image Filters 39 Frequency Filters Examples: (lowpass filters) Gaussian noise Original ILPF with with BLPF ILPF cut-off frequency frequency of of 1/2 1/3 cut-off 1/3 Image Filters 40 Frequency Filters Examples: (highpass filters) Image Filters 41 Frequency Filters Relationship and comparison with spatial filters – spatial filtering g ( x, y ) h ( x, y ) f ( x, y ) – frequency filtering G (u, v) H (u, v) F (u, v) – h( x, y ) H (u, v) Image Filters 42 Frequency Filters Comparison with spatial filters – more computational efficient – more intuitive Image Filters 43 Summary Filtering is the operation of applying a transform on an image in order to enhance it. Filtering techniques can be subdivided into two types – Spatial domain filtering – Frequency domain filtering Image Filters 44 Summary Filtering techniques are very useful in image analysis and processing – Noise removal – Edge detection Image Filters 45 Thank you The&end Questions ? Image Filters 46
© Copyright 2026 Paperzz