fourier transforms - cornell university · fourier transform for 1d images •a 1d image with n...

34
Fourier Transforms

Upload: others

Post on 30-Jan-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Fourier Transforms

Page 2: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Fourier transform for 1D images

• A 1D image with N pixels is a vector of size N• Every basis has N pixels• There must be N basis elements• n-th element of k-th basis in standard basis

• !" # = % 1 '( ) = #0 +,ℎ./0'1.

• n-th element of k-th basis in Fourier basis• 2" # = .

345678

Page 3: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Fourier transform for 1D images

• Converting from standard basis to Fourier basis = Fourier transform• ! " = ∑%& ' ()

*+,-./

• Note that can be written as a matrix multiplication with X and x as vectors• ! = 0&

• Convert from Fourier basis to standard basis• & ' = ∑1! " (

*+,-./

Page 4: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Fourier transform

• Problem: basis is complex, but signal is real?• Combine a pair of conjugate basis elements

• !"#$ n = '()* +,- .

+ = '/012 #()*-.+ = '#

()*-.+ = !#$ 3

• Consider !#"/0 to !"/0 as basis elements• Real signals will have same coefficients for !$ and !#$

Page 5: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Visualizing the Fourier basis for 1D images

Page 6: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Signal Fourier transform

cosimpulse

impulse cos

Page 7: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Fourier transform for images

• Images are 2D arrays• Fourier basis for 1D array indexed by frequence• Fourier basis elements are indexed by 2 spatial frequencies• (i,j)th Fourier basis for N x N image• Has period N/i along x• Has period N/j along y

• !",$ %, & = ()*+,-. /)*+01.

= cos 267%8 + 26:&8 + ; sin (267%8 + 26:&8 )

Page 8: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Visualizing the Fourier basis for images!"," !$,%&

!"&,"!&,&

Page 9: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Visualizing the Fourier transform

• Given NxN image, there are NxN basis elements• Fourier coefficients can be represented as an NxN image

Page 10: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Converting to and from the Fourier basis

• Given an image f, Fourier coefficients F• How do we get f from F?• ! = ∑$,& ' (, ) *$,&• ! +, , = ∑$,& ' (, ) -.

/0123 4/0563

• “Inverse Fourier Transform”• How do we get F from f?• ' (, ) = ∑7,8 ! +, , -9.

/0123 4/0:563

• “Fourier Transform”

Page 11: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Why Fourier transforms?

• Think of image in terms of low and high frequency information• Low frequency: large scale structure, no details• High frequency: fine structure

Page 12: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Why Fourier transforms?

Page 13: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Why Fourier transforms?

Page 14: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Why Fourier transforms?

Removing high frequency components looks like blurring. Is there more to this relationship?

Page 15: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Dual domains

• Image: Spatial domain

• Fourier Transform: Frequency domain• Amplitudes are called spectrum

• For any transformations we do in spatial domain, there are corresponding transformations we can do in the frequency domain• And vice-versa

Spatial Domain

Page 16: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Dual domains

• Convolution in spatial domain = Point-wise multiplication in frequency domain

• Convolution in frequency domain = Point-wise multiplication in spatial domain

h = f ⇤ gH = FG

Page 17: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Signal Fourier transform

cosimpulse

impulse cos

Page 18: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Signal Fourier transform

box “sinc” = sin(x)/x

“sinc” = sin(x)/x box

Page 19: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Signal Fourier transform

Gaussian Gaussian

Page 20: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Signal Fourier transform

Gaussian Gaussian

Page 21: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Image Fourier transform

Page 22: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Image Fourier transform

Page 23: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Detour: Time complexity of convolution

• Image is w x h• Filter is k x k• Every entry takes O(k2) operations• Number of output entries:• (w+k-1)(h+k-1) for full• wh for same

• Total time complexity: • O(whk2)

Page 24: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Optimization: separable filters• basic alg. is O(r2): large filters get expensive fast!• definition: w(x,y) is separable if it can be written as:

• Write u as a k x 1 filter, and v as a 1 x k filter• Claim:

Page 25: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1

Page 26: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2

Page 27: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2 u1v3

Page 28: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2 u1v3

u2v1

Page 29: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2 u1v3

u2v1 u2v2

Page 30: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2 u1v3

u2v1 u2v2 u2v3

Page 31: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2 u1v3

u2v1 u2v2 u2v3

u3v1

Page 32: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2 u1v3

u2v1 u2v2 u2v3

u3v1 u3v2

Page 33: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filtersu1u2u3

v1 v2 v3*

u1u2u3

u3u2u1

u1v1 u1v2 u1v3

u2v1 u2v2 u2v3

u3v1 u3v2 u3v3

w

Page 34: Fourier Transforms - Cornell University · Fourier transform for 1D images •A 1D image with N pixels is a vector of size N •Every basis has N pixels •TheremustbeNbasiselements

Separable filters

• Time complexity of original : O(whk2)• Time complexity of separable version : O(whk)