Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Frequency Domain Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve Seitz CS194: Image Manipulation & Computational Photography Alexei.

Similar presentations


Presentation on theme: "The Frequency Domain Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve Seitz CS194: Image Manipulation & Computational Photography Alexei."— Presentation transcript:

1 The Frequency Domain Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve Seitz CS194: Image Manipulation & Computational Photography Alexei Efros, UC Berkeley, Fall 2014

2 Salvador Dali, “Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln”, 1976 Salvador Dali “Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln”, 1976

3

4

5 A nice set of basis This change of basis has a special name… Teases away fast vs. slow changes in the image.

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

7 A sum of sines Our building block: Add enough of them to get any signal f(x) you want! How many degrees of freedom? What does each control? Which one encodes the coarse vs. fine structure of the signal?

8 Fourier Transform We want to understand the frequency  of our signal. So, let’s reparametrize the signal by  instead of x: f(x) F(  ) Fourier Transform F(  ) f(x) Inverse Fourier Transform For every  from 0 to inf, F(  ) holds the amplitude A and phase  of the corresponding sine How can F hold both? We can always go back:

9 Time and Frequency example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

10 Time and Frequency example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t) = +

11 Frequency Spectra example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t) = +

12 Frequency Spectra Usually, frequency is more interesting than the phase

13 = + = Frequency Spectra

14 = + =

15 = + =

16 = + =

17 = + =

18 =

19

20 FT: Just a change of basis...... * = M * f(x) = F(  )

21 IFT: Just a change of basis...... * = M -1 * F(  ) = f(x)

22 Finally: Scary Math

23 …not really scary: is hiding our old friend: So it’s just our signal f(x) times sine at frequency  phase can be encoded by sin/cos pair

24 Extension to 2D Image as a sum of basis images =

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

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

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

28 Man-made Scene

29 Can change spectrum, then reconstruct Local change in one domain, courses global change in the other

30 Low and High Pass filtering

31 The Convolution Theorem The greatest thing since sliced (banana) bread! The Fourier transform of the convolution of two functions is the product of their Fourier transforms The inverse Fourier transform of the product of two Fourier transforms is the convolution of the two inverse Fourier transforms Convolution in spatial domain is equivalent to multiplication in frequency domain!

32 2D convolution theorem example * f(x,y)f(x,y) h(x,y)h(x,y) g(x,y)g(x,y) |F(s x,s y )| |H(s x,s y )| |G(s x,s y )|

33 Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts? GaussianBox filter Filtering

34 Fourier Transform pairs

35 Gaussian

36 Box Filter

37 Low-pass, Band-pass, High-pass filters low-pass: High-pass / band-pass:

38 Edges in images

39 What does blurring take away? original

40 What does blurring take away? smoothed (5x5 Gaussian)

41 High-Pass filter smoothed – original

42 Image “Sharpening” What does blurring take away? original smoothed (5x5) – detail = sharpened = Let’s add it back: originaldetail + α

43 Unsharp mask filter Gaussian unit impulse Laplacian of Gaussian image blurred image unit impulse (identity)

44 Hybrid Images Gaussian Filter! Laplacian Filter! A. Oliva, A. Torralba, P.G. Schyns, “Hybrid Images,” SIGGRAPH 2006 “Hybrid Images,” Gaussian unit impulse Laplacian of Gaussian

45 Salvador Dali, “Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln”, 1976 Salvador Dali “Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln”, 1976

46 Band-pass filtering Laplacian Pyramid (subband images) Created from Gaussian pyramid by subtraction Gaussian Pyramid (low-pass images)

47 Laplacian Pyramid How can we reconstruct (collapse) this pyramid into the original image? Need this! Original image

48 Blending

49 Alpha Blending / Feathering 0 1 0 1 + = I blend =  I left + (1-  )I right

50 Affect of Window Size 0 1 left right 0 1

51 Affect of Window Size 0 1 0 1

52 Good Window Size 0 1 “Optimal” Window: smooth but not ghosted

53 What is the Optimal Window? To avoid seams window = size of largest prominent feature To avoid ghosting window <= 2*size of smallest prominent feature Natural to cast this in the Fourier domain largest frequency <= 2*size of smallest frequency image frequency content should occupy one “octave” (power of two) FFT

54 What if the Frequency Spread is Wide Idea (Burt and Adelson) Compute F left = FFT(I left ), F right = FFT(I right ) Decompose Fourier image into octaves (bands) –F left = F left 1 + F left 2 + … Feather corresponding octaves F left i with F right i –Can compute inverse FFT and feather in spatial domain Sum feathered octave images in frequency domain Better implemented in spatial domain FFT

55 Octaves in the Spatial Domain Bandpass Images Lowpass Images

56 Pyramid Blending 0 1 0 1 0 1 Left pyramidRight pyramidblend

57 Pyramid Blending

58 laplacian level 4 laplacian level 2 laplacian level 0 left pyramidright pyramidblended pyramid

59 Blending Regions

60 Laplacian Pyramid: Blending General Approach: 1.Build Laplacian pyramids LA and LB from images A and B 2.Build a Gaussian pyramid GR from selected region R 3.Form a combined pyramid LS from LA and LB using nodes of GR as weights: LS(i,j) = GR(I,j,)*LA(I,j) + (1-GR(I,j))*LB(I,j) 4.Collapse the LS pyramid to get the final blended image

61 Horror Photo © david dmartin (Boston College)

62 Results from this class (fall 2005) © Chris Cameron

63 Season Blending (St. Petersburg)

64

65 Simplification: Two-band Blending Brown & Lowe, 2003 Only use two bands: high freq. and low freq. Blends low freq. smoothly Blend high freq. with no smoothing: use binary alpha

66 Low frequency ( > 2 pixels) High frequency ( < 2 pixels) 2-band Blending

67 Linear Blending

68 2-band Blending

69 “Style Transfer for Headshot Portraits” (SIGGRAPH ‘14)

70 Pipeline Input Example Step 1: matching Step 2: transfer

71

72

73

74

75 Example Laplacian Local energy Gaussian kernel at this scale

76 At each scale: match local energy Example energyInput energy

77 At each scale: match local energy Compute the gain map Example Laplacian Input Laplacian Local energy S[E] Local energy S[I] Gain map =

78 At each scale: match local energy Compute the gain map Example Laplacian Input Laplacian Local energy S[E] Local energy S[I] Modulate the input Laplacian Input LaplacianGain map Output Laplacian × = Gain map =


Download ppt "The Frequency Domain Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve Seitz CS194: Image Manipulation & Computational Photography Alexei."

Similar presentations


Ads by Google