1 / 58

Mestrado em Ciência de Computadores

Explore spatial filters, frequency domain filtering, and edge detection in image processing. Learn practical implementations of convolution, Gaussian smoothing, mean filtering, and edge detection methods.

rstenson
Download Presentation

Mestrado em Ciência de Computadores

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VC 14/15 – TP7Spatial Filters Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos Miguel Tavares Coimbra

  2. Outline • Spatial filters • Frequency domain filtering • Edge detection Acknowledgements: Most of this course is based on the excellent courses offered by Prof. Shree Nayar at Columbia University, USA and by Prof. Srinivasa Narasimhan at CMU, USA. Please acknowledge the original source when reusing these slides for academic purposes. VC 14/15 - TP7 - Spatial Filters

  3. Topic: Spatial filters • Spatial filters • Frequency domain filtering • Edge detection VC 14/15 - TP7 - Spatial Filters

  4. Images are Discrete and Finite Convolution Fourier Transform Inverse Fourier Transform VC 14/15 - TP7 - Spatial Filters

  5. Simple way to process an image. Mask defines the processing function. Corresponds to a multiplication in frequency domain. Spatial Mask Mask Image Convolution – Mask ‘slides’ over the image VC 14/15 - TP7 - Spatial Filters

  6. Each mask position has weight w. The result of the operation for each pixel is given by: Example Mask Image =1*2+2*2+1*2+… =8+0-20 =-12 VC 14/15 - TP7 - Spatial Filters

  7. Definitions • Spatial filters • Use a mask (kernel) over an image region. • Work directly with pixels. • As opposed to: Frequency filters. • Advantages • Simple implementation: convolution with the kernel function. • Different masks offer a large variety of functionalities. VC 14/15 - TP7 - Spatial Filters

  8. For n=2, convolve pixel values with 2D images: 1 1 1 2 1 then (a) use or (b) use 1 1 1 2 2 2 1 1 1 2 2 4 2 2 1 2 1 1 1 Averaging Let’s think about averaging pixel values Which is faster? VC 14/15 - TP7 - Spatial Filters

  9. large Repeated averaging Gaussian smoothing Averaging The convolution kernel VC 14/15 - TP7 - Spatial Filters

  10. pixels Filter size …can be very large 2D Gaussian is separable! Gaussian Smoothing Gaussiankernel (truncate, if necessary) Use two 1DGaussianFilters! VC 14/15 - TP7 - Spatial Filters

  11. Gaussian Smoothing • A Gaussian kernel gives less weight to pixels further from the center of the window • This kernel is an approximation of a Gaussian function: VC 14/15 - TP7 - Spatial Filters

  12. original VC 14/15 - TP7 - Spatial Filters

  13. Mean Filtering • We are degrading the energy of the high spatial frequencies of an image (low-pass filtering). • Makes the image ‘smoother’. • Used in noise reduction. • Can be implemented with spatial masks or in the frequency domain. VC 14/15 - TP7 - Spatial Filters

  14. Mean filter Gaussian filter VC 14/15 - TP7 - Spatial Filters

  15. VC 14/15 - TP7 - Spatial Filters http://www.michaelbach.de/ot/cog_blureffects/index.html

  16. VC 14/15 - TP7 - Spatial Filters http://www.michaelbach.de/ot/cog_blureffects/index.html

  17. Median filtering sort median Median Filter (a) • Smoothing is averaging (a) Blurs edges (b) Sensitive to outliers (b) • Sort values around the pixel • Select middle value (median) • Non-linear (Cannot be implemented with convolution) VC 14/15 - TP7 - Spatial Filters

  18. Gaussian noise Salt and pepper noise 3x3 5x5 7x7 VC 14/15 - TP7 - Spatial Filters

  19. What a computer sees Border Problem How do we apply our mask to this pixel? VC 14/15 - TP7 - Spatial Filters

  20. Border Problem • Ignore • Output image will be smaller than original • Pad with constant values • Can introduce substantial 1st order derivative values • Pad with reflection • Can introduce substantial 2nd order derivative values VC 14/15 - TP7 - Spatial Filters

  21. Topic: Frequency domain filtering • Spatial filters • Frequency domain filtering • Edge detection VC 14/15 - TP7 - Spatial Filters

  22. Image Processing in the Fourier Domain Magnitude of the FT Does not look anything like what we have seen VC 14/15 - TP7 - Spatial Filters

  23. Convolution in the Frequency Domain |F(sx,sy)| f(x,y) h(x,y) |H(sx,sy)| g(x,y) |G(sx,sy)| VC 14/15 - TP7 - Spatial Filters

  24. Low-pass Filtering Lets the low frequencies pass and eliminates the high frequencies. Generates image with overall shading, but not much detail VC 14/15 - TP7 - Spatial Filters

  25. High-pass Filtering Lets through the high frequencies (the detail), but eliminates the low frequencies (the overall shape). It acts like an edge enhancer. VC 14/15 - TP7 - Spatial Filters

  26. Boosting High Frequencies VC 14/15 - TP7 - Spatial Filters

  27. VC 14/15 - TP7 - Spatial Filters

  28. VC 14/15 - TP7 - Spatial Filters

  29. The Ringing Effect An ideal low-pass filter causes ‘rings’ in the spatial domain! http://homepages.inf.ed.ac.uk/rbf/HIPR2/freqfilt.htm VC 14/15 - TP7 - Spatial Filters

  30. Topic: Edge detection • Spatial filters • Frequency domain filtering • Edge detection VC 14/15 - TP7 - Spatial Filters

  31. Convert a 2D image into a set of curves Extracts salient features of the scene More compact than pixels Edge Detection VC 14/15 - TP7 - Spatial Filters

  32. Edges are caused by a variety of factors Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity VC 14/15 - TP7 - Spatial Filters

  33. How can you tell that a pixel is on an edge? VC 14/15 - TP7 - Spatial Filters

  34. Edge Types Step Edges Line Edges Roof Edge VC 14/15 - TP7 - Spatial Filters

  35. Edge Magnitude Edge Orientation High Detection Rate and Good Localization Real Edges Noisy and Discrete! We want an Edge Operator that produces: VC 14/15 - TP7 - Spatial Filters

  36. Gradient • Gradient equation: • Represents direction of most rapid change in intensity • Gradient direction: • The edge strength is givenby the gradient magnitude VC 14/15 - TP7 - Spatial Filters

  37. Ideal edge Unit step function: Image intensity (brightness): Theory of Edge Detection VC 14/15 - TP7 - Spatial Filters

  38. Partial derivatives (gradients): • Squared gradient: Edge Magnitude: (normal of the edge) Edge Orientation: Rotationally symmetric, non-linear operator Theory of Edge Detection VC 14/15 - TP7 - Spatial Filters

  39. Laplacian: Rotationally symmetric, linear operator zero-crossing Theory of Edge Detection VC 14/15 - TP7 - Spatial Filters

  40. Discrete Edge Operators • How can we differentiate a discrete image? Finite difference approximations: Convolution masks : VC 14/15 - TP7 - Spatial Filters

  41. Second order partial derivatives: • Laplacian : Convolution masks : or Discrete Edge Operators (more accurate) VC 14/15 - TP7 - Spatial Filters

  42. The Sobel Operators • Better approximations of the gradients exist • The Sobel operators below are commonly used VC 14/15 - TP7 - Spatial Filters

  43. Comparing Edge Operators Good Localization Noise Sensitive Poor Detection Gradient: Roberts (2 x 2): Sobel (3 x 3): Sobel (5 x 5): Poor Localization Less Noise Sensitive Good Detection VC 14/15 - TP7 - Spatial Filters

  44. Effects of Noise • Consider a single row or column of the image • Plotting intensity as a function of position gives a signal Where is the edge?? VC 14/15 - TP7 - Spatial Filters

  45. Solution: Smooth First Look for peaks in Where is the edge? VC 14/15 - TP7 - Spatial Filters

  46. Derivative Theorem of Convolution …saves us one operation. VC 14/15 - TP7 - Spatial Filters

  47. Laplacian of Gaussian (LoG) Laplacian of Gaussian Laplacian of Gaussian operator Where is the edge? Zero-crossings of bottom graph ! VC 14/15 - TP7 - Spatial Filters

  48. 2D Gaussian Edge Operators Derivative of Gaussian (DoG) Laplacian of Gaussian Gaussian Mexican Hat (Sombrero) • is the Laplacian operator: VC 14/15 - TP7 - Spatial Filters

  49. Canny Edge Operator • Smooth image I with 2D Gaussian: • Find local edge normal directions for each pixel • Compute edge magnitudes • Locate edges by finding zero-crossings along the edge normal directions (non-maximum suppression) VC 14/15 - TP7 - Spatial Filters

  50. Non-maximum Suppression • Check if pixel is local maximum along gradient direction • requires checking interpolated pixels p and r VC 14/15 - TP7 - Spatial Filters

More Related