thinking in frequency
play

Thinking in Frequency Computer Vision Jia-Bin Huang, Virginia Tech - PowerPoint PPT Presentation

Thinking in Frequency Computer Vision Jia-Bin Huang, Virginia Tech Dali: Gala Contemplating the Mediterranean Sea (1976) Administrative stuffs HW 0 will be posted on Sunday (Sept 2). Due date: Sept 10 HW 1 will be posted on


  1. Thinking in Frequency Computer Vision Jia-Bin Huang, Virginia Tech Dali: “Gala Contemplating the Mediterranean Sea” (1976)

  2. Administrative stuffs • HW 0 will be posted on Sunday (Sept 2). • Due date: Sept 10 • HW 1 will be posted on Sunday (Sept 2) • Due date: Sept 17

  3. Previous class: Image Filtering • Linear filtering is sum of dot 1 1 1 product at each position 1 1 1 1 1 1 • Can smooth, sharpen, translate (among many other uses) • Gaussian filters • Low pass filters, separability, variance • Attend to details: • filter size, extrapolation, cropping • Applications: • Texture representation • Noise models and nonlinear image filters

  4. Today’s class • Review of image filtering in spatial domain • Fourier transform and frequency domain • Frequency view of filtering • Image downsizing and interpolation • Goals: • Understand 2D Fourier transform • Understand how to implement filtering in Fourier domain • Understand aliasing and how to prevent aliasing

  5. Demo • http://setosa.io/ev/image-kernels/

  6. Review: questions Filtering Operator a) _ = D * B A Fill in the blanks: b) A = _ * _ c) F = D * _ d) _ = D * D B E G C F H I D Slide: Hoiem

  7. Representing texture by mean abs response Filters Mean abs responses

  8. Denoising and Nonlinear Image Filtering • Salt and pepper noise : contains random occurrences of black and white pixels • Impulse noise: contains random occurrences of white pixels • Gaussian noise : variations in intensity drawn from a Gaussian normal distribution Source: S. Seitz

  9. Gaussian noise •Mathematical model: sum of many independent factors •Good for small standard deviations •Assumption: independent, zero-mean noise Source: M. Hebert

  10. Reducing Gaussian noise Smoothing with larger standard deviations suppresses noise, but also blurs the image

  11. Reducing salt-and-pepper noise 3x3 5x5 7x7 • What’s wrong with the results?

  12. Alternative idea: Median filtering •A median filter operates over a window by selecting the median intensity in the window • Is median filtering linear? Source: K. Grauman

  13. Median filter • Is median filtering linear? • Let’s try filtering

  14. Median filter • What advantage does median filtering have over Gaussian filtering? • Robustness to outliers Source: K. Grauman

  15. Median filter Salt-and-pepper noise Median filtered • MATLAB: medfilt2(image, [h w]) Source: M. Hebert

  16. Gaussian vs. median filtering 3x3 5x5 7x7 Gaussian Median

  17. Other non-linear filters • Weighted median (pixels further from center count less) • Clipped mean (average, ignoring few brightest and darkest pixels) • Bilateral filtering (weight by spatial distance and intensity difference) Bilateral filtering Image: http://vision.ai.uiuc.edu/?p=1455

  18. Bilateral Filters • Edge preserving: weights similar pixels more Bilateral Original Gaussian spatial similarity (e.g., intensity) Carlo Tomasi, Roberto Manduchi, Bilateral Filtering for Gray and Color Images, ICCV, 1998.

  19. Previous class: Image Filtering • Linear filtering is sum of dot 1 1 1 product at each position 1 1 1 1 1 1 • Can smooth, sharpen, translate (among many other uses) • Gaussian filters • Low pass filters, separability, variance • Attend to details: • filter size, extrapolation, cropping • Applications: • Texture representation • Noise models and nonlinear image filters

  20. Hybrid Images • A. Oliva, A. Torralba, P.G. Schyns, “Hybrid Images,” SIGGRAPH 2006 Slide credit: Derek Hoiem

  21. Why do we get different, distance-dependent interpretations of hybrid images? ? Slide credit: Derek Hoiem

  22. Why does a lower resolution image still make sense to us? What do we lose? Slide credit: Derek Hoiem Image: http://www.flickr.com/photos/igorms/136916757/

  23. Thinking in terms of frequency

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

  25. How would math have changed if the Slanket or Snuggie had been invented? Slide credit: James Hays

  26. A sum of sines Our building block: ω x + φ ) A sin( Add enough of them to get any signal f(x) you want!

  27. Frequency Spectra • example : g ( t ) = sin( 2 π f t ) + ( 1/3 )sin( 2 π ( 3f ) t ) = + Slides: Efros

  28. Frequency Spectra

  29. Frequency Spectra = + =

  30. Frequency Spectra = + =

  31. Frequency Spectra = + =

  32. Frequency Spectra = + =

  33. Frequency Spectra = + =

  34. Frequency Spectra ∞ 1 sin(2 ∑ = π A kt ) k = k 1

  35. Example: Music • We think of music in terms of frequencies at different magnitudes

  36. Other signals • We can also think of all kinds of other signals the same way Cats(?) xkcd.com

  37. Fourier analysis in images Intensity Image Fourier Image http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering

  38. Signals can be composed + = http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering More: http://www.cs.unm.edu/~brayer/vision/fourier.html

  39. Fourier Transform Teases away fast vs. slow changes in the image. Image as a sum of basis images Slide credit: A Efros

  40. Extension to 2D in Matlab, check out: imagesc(log(abs(fftshift(fft2(im)))));

  41. 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 ω I ( ) φ = − = ± ω + ω 2 2 tan 1 A R ( ) I ( ) Amplitude: Phase: ω R ( ) Euler’s formula:

  42. Salvador Dali invented Hybrid Images? Salvador Dali “Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln ”, 1976

  43. Strong Vertical Frequency (Sharp Horizontal Edge) Diagonal Frequencies Strong Horz. Frequency (Sharp Vert. Edge) Log Magnitude Low Frequencies

  44. Man-made Scene

  45. Can change spectrum, then reconstruct

  46. Low and High Pass filtering

  47. Computing the Fourier Transform Discrete Continuous k = -N/2..N/2 Fast Fourier Transform (FFT): NlogN

  48. Properties of Fourier Transforms • Linearity • Fourier transform of a real signal is symmetric about the origin • The energy of the signal is the same as the energy of its Fourier transform See Szeliski Book (3.4)

  49. 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 ] • The inverse Fourier transform of the product of two Fourier transforms is the convolution of the two inverse Fourier transforms − − − = ∗ 1 1 1 F [ gh ] F [ g ] F [ h ] • Convolution in spatial domain is equivalent to multiplication in frequency domain!

  50. 1 0 -1 2 0 -2 Filtering in spatial domain 1 0 -1 = *

  51. Spatial domain = * FFT FFT Inverse FFT = Frequency domain

  52. FFT in Matlab • Filtering with fft im = … % im: gray-scale floating point image [imh, imw] = size(im); fftsize = 1024; % fftsize: should be order of 2 (for speed) and include padding hs = 50; % fil: Gaussian filter fil = fspecial('gaussian', hs*2+1, 10); % im_fft = fft2(im, fftsize, fftsize); % 1) fft im with padding fil_fft = fft2(fil, fftsize, fftsize); % 2) fft fil, pad to same size as image im_fil_fft = im_fft .* fil_fft; % 3) multiply fft images im_fil = ifft2(im_fil_fft); % 4) inverse fft2 im_fil = im_fil(1+hs:size(im,1)+hs, 1+hs:size(im, 2)+hs); % 5) remove padding • Displaying with fft figure(1), imagesc(log(abs(fftshift(im_fft)))), axis image, colormap jet

  53. Questions Which has more information, the phase or the magnitude? What happens if you take the phase from one image and combine it with the magnitude from another image?

  54. Phase vs. Magnitude Use random magnitude Inverse FFT Intensity image FFT Use random phase Inverse FFT Magnitude Phase

  55. Filtering Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts? Gaussian Box filter

  56. Gaussian

  57. Box Filter

  58. Question Match the spatial domain image to the Fourier magnitude image 2 3 1 4 5 B C E A D

  59. 2-mins break

  60. Image half-sizing This image is too big to fit on the screen. How can we reduce it? How to generate a half- sized version?

Recommend


More recommend