filtering frequency and edges
play

Filtering, Frequency, and Edges Various slides from previous courses - PowerPoint PPT Presentation

CS4501: Introduction to Computer Vision Filtering, Frequency, and Edges Various slides from previous courses by: D.A. Forsyth (Berkeley / UIUC), I. Kokkinos (Ecole Centrale / UCL). S. Lazebnik (UNC / UIUC), S. Seitz (MSR / Facebook), J. Hays


  1. CS4501: Introduction to Computer Vision Filtering, Frequency, and Edges Various slides from previous courses by: D.A. Forsyth (Berkeley / UIUC), I. Kokkinos (Ecole Centrale / UCL). S. Lazebnik (UNC / UIUC), S. Seitz (MSR / Facebook), J. Hays (Brown / Georgia Tech), A. Berg (Stony Brook / UNC), D. Samaras (Stony Brook) . J. M. Frahm (UNC), V. Ordonez (UVA).

  2. Last Class • Convolution Operation • Image Blurring / Gaussian Blur • Image Gradients: The Sobel Operator

  3. Today’s Class • Recap on Sobel Operator • Filtering in Frequency • Canny Edge Detector (also next class)

  4. Image filtering: Convolution operator Important Filter: Sobel operator 1 0 -1 2 0 -2 !(#, %) = 1 0 -1 !(#, %) Image Credit: http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/

  5. Other filters 1 0 -1 2 0 -2 1 0 -1 Sobel Vertical Edge (absolute value) Slide by James Hays

  6. Other filters 1 2 1 0 0 0 -1 -2 -1 Sobel Horizontal Edge (absolute value) Slide by James Hays

  7. Sobel operators are equivalent to 2D partial derivatives of the image • Vertical sobel operator – Partial derivative in X (width) • Horizontal sobel operator – Partial derivative in Y (height) • Can compute magnitude and phase at each location. • Useful for detecting edges

  8. https://en.wikipedia.org/wiki/Sobel_operator

  9. Sobel filters are (approximate) partial derivatives of the image Let "($, &) be your input image, then the partial derivative is: !"($, &) " $ + ℎ, & − "($, &) = lim !$ ℎ ,→. !"($, &) " $ + ℎ, & − "($ − ℎ, &) Also: = lim !$ 2ℎ ,→.

  10. But digital images are not continuous, they are discrete Let #[%, '] be your input image, then the partial derivative is: Δ " #[%, '] = #[% + 1, '] − #[%, '] Also: Δ " #[%, '] = #[% + 1, '] − #[% − 1, ']

  11. But digital images are not continuous, they are discrete Let #[%, '] be your input image, then the partial derivative is: Δ " #[%, '] = #[% + 1, '] − #[%, '] k(x, y) = -1 1 Also: Δ " #[%, '] = #[% + 1, '] − #[% − 1, '] k(x, y) = -1 0 1

  12. Frequency Figure by National Instruments

  13. Any function can be approximated by a polynomial function Taylor Series expansion …if you let your polynomial have a high degree …AND you can compute the derivatives of the original function easily.

  14. Difficult in practice https://brilliant.org/wiki/taylor-series-approximation/

  15. Jean Baptiste Joseph Fourier (1768-1830) ...the manner in which the author arrives at these had crazy idea (1807): equations is not exempt of difficulties and...his analysis to integrate them still leaves something to Any univariate function can be be desired on the score of generality and even rewritten as a weighted sum of rigour . sines and cosines of different frequencies. • Don’t believe it? – Neither did Lagrange, Laplace Laplace, Poisson and other big wigs – Not translated into English until 1878! • But it’s (mostly) true! Legendre – called Fourier Series Lagrange – there are some subtle restrictions Slide by James Hays

  16. Example Slide by Emmanuel Agu

  17. Discrete Fourier Transform ()* cos −22 ," + 5 sin −22 ," ! " = $ + , 3 3 %&'

  18. Keep in mind Euler’s Equation ! "# = cos ( + * sin ( We can compute the real and the imaginary part of the complex number.

  19. Discrete Fourier Transform ()* cos −22 ," + 3 sin −22 ," ! " = $ + , 4 4 %&' ()* + , exp −223 ," ! " = $ 4 %&'

  20. Discrete ()* + , exp −223 ," Fourier ! " = $ 4 Transform %&' ()* Inverse + , = 1 ! " exp 223 ," 4 $ Discrete Fourier 4 Transform 6&'

  21. More generally for images (2D DFT and iDFT) *+, .+, / 0, 1 exp −278 0" 9 + 1$ ! ", $ = & & ; '() -() *+, .+, 1 ! ", $ exp 278 0" 9 + 1$ / 0, 1 = 9; & & ; =() >()

  22. Discrete Fourier Transform - Visualization Slide by A. Zisserman

  23. Fourier Transform • Fourier transform stores the magnitude and phase at each frequency • Magnitude encodes how much signal there is at a particular frequency • Phase encodes spatial information (indirectly) • For mathematical convenience, this is often notated in terms of real and complex numbers w I ( ) - = ± w + w f = 2 2 tan 1 A R ( ) I ( ) Amplitude: Phase: w R ( ) Slide by James Hays

  24. Image Filtering in the Frequency Domain Slide by A. Zisserman

  25. Image Filtering in the Frequency Domain Slide by A. Zisserman

  26. Image Filtering in the Frequency Domain Slide by A. Zisserman

  27. The Convolution Theorem • The Fourier transform of the convolution of two functions is the product of their Fourier transforms * = F[ g h ] F[ g ] F[ h ] • Convolution in spatial domain is equivalent to multiplication in frequency domain! = - 1 g * h F [F[ g ] F[ h ]] How can this be useful?

  28. Blurring in the Time vs Frequency Domain Example by A. Zisserman

  29. Blurring in the Time vs Frequency Domain Example by A. Zisserman

  30. Blurring in the Time vs Frequency Domain Example by A. Zisserman

  31. Why Frequency domain? • Because the Discrete Fourier Transform can be computed fast using the Fast Fourier Transform FFT algorithm. • Because the running time does not depend on the size of the kernel matrix. • However rarely used these days because most filters used in Computer vision are 3x3, 5x5, e.g. relatively small.

  32. Final Thoughts – JPEG Image Compression Small amount of information can • recover almost the original image with some loss in resolution. Images are dominated by low • frequency information. e.g. no need to store repeated pixels. In practice JPEG uses a simpler • transformation called Discrete Cosine Transform DCT.

  33. Questions? 34

  34. Edge Detection

  35. Edge Detection • Goal: Identify sudden changes (discontinuities) in an image • Intuitively, most semantic and shape information from the image can be encoded in the edges • More compact than pixels • Ideal: artist’s line drawing (but artist is also using object-level knowledge) Source: D. Lowe

  36. Why do we care about edges? • Extract information, recognize objects Vertical vanishing • Recover geometry and viewpoint point (at infinity) Vanishing line Vanishing Vanishing point point Source: J. Hays

  37. Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity • Edges are caused by a variety of factors Source: Steve Seitz

  38. Edge Detection But Ideally we want an output where: g(x,y) = 1 if edge • Back to Sobel g(x,y) = 0 if background

  39. Edge Detection ! ", $ = &1, ((", $) ≥ , • Sobel + Thresholding 0, ( ", $ < ,

  40. ! ", $ = &1, ((", $) ≥ , • Sobel + Thresholding 0, ( ", $ < , Problems: • Edges are too wide: We want 1-pixel wide edges if possible. • Lots of disconnected edges: We want to respect continuity or connectivity.

  41. Solution: Canny edge detector • Suppress Noise Similar to Sobel: Blurring + Gradients • Compute gradient magnitude and direction • Non-Maximum Suppression • Hysteresis and connectivity analysis

  42. Example • original image Source: Juan C. Niebles and Ranjay Krishna.

  43. Derivative of Gaussian filter y -direction x -direction Source: Juan C. Niebles and Ranjay Krishna.

  44. Compute gradients (DoG) X-Derivative of Y-Derivative of Gradient Magnitude Gaussian Gaussian Source: J. Hays

  45. Get orientation at each pixel Source: J. Hays

  46. Compute gradients (DoG) X-Derivative of Y-Derivative of Gradient Magnitude Gaussian Gaussian Source: Juan C. Niebles and Ranjay Krishna.

  47. Canny edge detector • Suppress Noise • Compute gradient magnitude and direction • Apply Non-Maximum Suppression • Assures minimal response Source: Juan C. Niebles and Ranjay Krishna.

  48. Non-maximum suppression • Edge occurs where gradient reaches a maxima • Suppress non-maxima gradient even if it passes threshold • Only eight angle directions possible • Suppress all pixels in each direction which are not maxima • Do this in each marked pixel neighborhood Source: Juan C. Niebles and Ranjay Krishna.

  49. Remove spurious gradients is the gradient at pixel (x, y) !" #, % !" #, % !" #, % > !" #′, %′ !" #, % > !" #′′, %′′ Source: Juan C. Niebles and Ranjay Krishna.

  50. Non-maximum suppression • Edge occurs where gradient reaches a maxima • Suppress non-maxima gradient even if it passes threshold • Only eight angle directions possible • Suppress all pixels in each direction which are not maxima • Do this in each marked pixel neighborhood Source: Juan C. Niebles and Ranjay Krishna.

  51. Non-maximum suppression At q, we have a maximum if the value is larger than those at both p and at r. Interpolate to get these values. Source: D. Forsyth

  52. Non-max Suppression Before After Source: Juan C. Niebles and Ranjay Krishna.

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