digital image analysis and processing cpe 0907544
play

Digital Image Analysis and Processing CPE 0907544 Image Enhancement - PowerPoint PPT Presentation

Digital Image Analysis and Processing CPE 0907544 Image Enhancement Part II Spatial Filtering Chapter 3 Sections : 3.4-3.7 Dr. Iyad Jafar Outline Introduction Mechanics of Spatial Filtering Correlation and Convolution


  1. Digital Image Analysis and Processing CPE 0907544 Image Enhancement –Part II Spatial Filtering Chapter 3 Sections : 3.4-3.7 Dr. Iyad Jafar

  2. Outline  Introduction  Mechanics of Spatial Filtering  Correlation and Convolution  Linear Spatial Filtering  Spatial filters for Smoothing  Spatial filters for Sharpening  Nonlinear Spatial Filtering  Combining Spatial Enhancement T echniques 2

  3. Background  Filtering is borrowed from the frequency domain processing and refers to the process of passing or rejecting certain frequency components  Highpass, lowpass, band-reject , and bandpass filters  Filtering is achieved in the frequency domain by designing the proper filter (Chapter 4)  Filtering can be done in the spatial domain also by using filter masks (kernels, templates, or windows)  Unlike frequency domain filters, spatial filters can be nonlinear ! 3

  4. Spatial Filtering Mechanics  A spatial filter is characterized by  A rectangular neighborhood of size mxn (usually m and n are odd)  A predefined operation that is specified by the mask values at each position. Origin y w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) (x, y) Neighbourhood w(1,-1) w(1,0) w(1,1) 3x3 filter mask example x Image f (x, y)  Spatial filtering Operation  The filter mask is centered at each pixel in the image and the output pixel value is computed based on the operation specified by the mask 4

  5. Spatial Filtering Mechanics Origin y f(x-1,y-1) f(x-1,y) f(x-1,y+1) w(-1,-1) w(-1,0) w(-1,1) 3x3 Filter x x Image f (x, y) w(0,-1) w(0,0) w(0,1) f(x,y-1) f(x,y) f(x,y+1) w(1,-1) w(1,0) w(1,1) f(x+1,y-1) f(x+1,y) f(x+1,y+11) Filter Original Image Pixels a b      g( x,y ) w( s,t ) f ( x s,y t )   s a t b 5

  6. Vector Representation of Spatial Filtering  The previous filtering equation can be written as     R w z w z ... w z 1 1 2 2 mn mn w1 w2 w3 mn  w4 w5 w6 = w z k k w7 w8 w9  k 1  If we represent the coefficients of the filter mask as a row vector w = [w 1 w 2 w 3 w 4 w 5 w 6 w 7 w 8 w 9 ] and the image pixels under the mask by z = [z 1 z 2 z 3 z 4 z 5 z 6 z 7 z 8 z 9 ], then the filtering equation can be written as T  R wz 6

  7. Spatial Correlation  The filtering operation just described is called correlation  In 1-D Origin f w 0 0 0 1 0 0 0 0 1 2 3 2 8 1) Function and mask 0 0 0 1 0 0 0 0 2) Initial Alignment 1 2 3 2 8 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 3) Zero Padding for f by m-1 1 2 3 2 8 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 4) Position after one shift 1 2 3 2 8 7

  8. Spatial Correlation 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 5) Position after 4 shifts 1 2 3 2 8 . . 6) Repeat . 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 Final Position 1 2 3 2 8 0 0 0 8 2 3 2 1 0 0 0 0 Full correlation result 0 8 2 3 2 1 0 0 Cropped correlation 8 result

  9. Spatial Convolution  A strongly related operation to correlation is convolution (an important tool in linear systems theory)  The mechanics of convolution is similar to those of correlation, except that the filter mask is rotated by 180 o before sliding 9

  10. Spatial Convolution Origin f w 0 0 0 1 0 0 0 0 1 2 3 2 8 1) Function and mask 0 0 0 1 0 0 0 0 2) Initial Alignment 8 2 3 2 1 after rotation of mask 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 3) Zero Padding for f by m-1 8 2 3 2 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 4) Position after one shift 8 2 3 2 1 10

  11. Spatial Convolution 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 5) Position after 4 shifts 8 2 3 2 1 . . 6) Repeat . 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 Final Position 8 2 3 2 1 0 0 0 1 2 3 2 8 0 0 0 0 Full convolution result 0 1 2 3 2 8 0 0 Cropped convolution 11 result

  12. Extension to 2D  Extension to 2D is straight forward  Zero padding is done in both directions by m-1 and n-1  In convolution, the mask is flipped vertically and horizontally 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Zero padding by m-1 and n-1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 f 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 9 8 7 0 0 0 0 0 0 0 0 0 Mask rotation w 4 5 6 6 5 4 0 0 0 0 0 0 0 0 0 7 8 9 3 2 1 0 0 0 0 0 0 0 0 0 12

  13. Extension to 2D 1 2 3 0 0 0 0 0 0 9 8 7 0 0 0 0 0 0 4 5 6 0 0 0 0 0 0 6 5 4 0 0 0 0 0 0 7 8 9 0 0 0 0 0 0 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Initial position in convolution Initial position in correlation 13

  14. Extension to 2D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 8 7 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 6 5 4 0 0 0 0 0 0 4 5 6 0 0 0 0 0 0 3 2 1 0 0 0 0 0 0 7 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Full convolution result Full correlation result 14

  15. Extension to 2D 0 0 0 0 0 0 0 0 0 0 0 1 2 3 0 0 9 8 7 0 0 4 5 6 0 0 6 5 4 0 0 7 8 9 0 0 3 2 1 0 0 0 0 0 0 0 0 0 0 0 Cropped convolution result Cropped correlation result Correaltion Convolution a b a b         g( x,y ) w( s,t ) f ( x s,y t ) g( x,y ) w( s,t ) f ( x s,y t )     s a t b s a t b 15

  16. Treatment of Pixels at Edges  In the previous slides, we padded the image with zeros in both directions in order to compensate for unavailable values. x  Other approaches e e  Replicate edge pixels  Consider only available e pixels that fall under the e mask in the computation of the new values  Allow pixels to wrap e e e around y Image f (x, y) 16

  17. Treatment of Pixels at Edges  The result depends on the used approach  Example 3.6 Filtered Image: Zero Padding Original Filtered Image: Image Replicate Edge Pixels Filtered Image: Wrap Around Edge Pixels 17

  18. Smoothing Spatial Filters  A smoothing (averaging, blurring) filter replaces each pixel with the average value of all pixels under the mask  Uses of smoothing filters  The smoothed image correspond to the gross details of the image or the low frequency content of the image  Can be used to reduce noise as it is characterized with sharp transitions  However, smoothing usually results in degradation of edge quality (sharpness of the image) 18

  19. Smoothing Spatial Filters  Common smoothing masks 1 1 1 1 2 1 1 1 1 X 1/9 2 4 2 X 1/16 1 1 1 1 2 1 Standard averaging mask Weighted average mask  Notes  The weighted average filter gives more weight to pixels near the center  It is hard to see the visual difference between the processing results of the two filters; however, the weighted average filter coefficients sum up to 16, which makes it 19 more attractive for computers

  20. Smoothing Spatial Filters  Example: 3.7 Smoothing with different mask sizes. Notice the loss of details as the mask size increases Original Smoothing by 5x5 Mask Smoothing by 3x3 Mask 20 Smoothing by 35x35 Mask Smoothing by 9x9 Mask Smoothing by 15x15 Mask

  21. Smoothing Spatial Filters  Example 3.8: smoothing highlights gross details. Could be useful in providing better segmentation results Original Image Smoothed Image Thresholded Image 21

  22. Smoothing Spatial Filters  Example 3.9: Noise Reduction Original Smoothed 22

  23. Sharpening Spatial Filters  The principle objective of sharpening is to highlight transitions in intensity which usually correspond to edges in images; thus sharpening is the opposite of smoothing  If we examine the smoothing operation we can think of it as integration  Thus to perform sharpening in the spatial domain, it is intuitive to use differentiation  In the following few slides we examine the fundamental properties of the first and second derivatives when applied on different intensity transitions 23

  24. Sharpening Spatial Filters  Lets discuss differentiation for the1-D case  We are concerned about the behavior of 1 st and 2 nd derivatives in the following areas  Constant intensity  Onset and end of discontinuities (ramps and steps discontinuities)  Intensity ramps  Properties of 1 st derivative  Zero in areas of constant intensity  Nonzero at the onset of a step and intensity ramp  Nonzero along intensity ramp  Properties 2 nd derivative  Zero in areas of constant intensity  Nonzero at the onset and end of a step and intensity ramp  Zero along intensity ramp 24

  25. Sharpening Spatial Filters  Derivatives can be approximated as differences  1 st derivative at x   f   f ( x 1 ) f ( x )  x  2 nd derivative at x 2  f      f ( x 1 ) f ( x 1 ) 2 f ( x ) 2  x 25

  26. Sharpening Spatial Filters  Investigation of the derivatives behavior 26

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend