fourier transform in image processing - university of utah

101
Fourier Transform in Image Processing CS6640, Fall 2012 Guest Lecture Marcel Prastawa, SCI Utah

Upload: others

Post on 11-Sep-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fourier Transform in Image Processing - University of Utah

Fourier Transform

in

Image Processing

CS6640, Fall 2012

Guest Lecture

Marcel Prastawa, SCI Utah

Page 2: Fourier Transform in Image Processing - University of Utah

Preliminaries

Page 3: Fourier Transform in Image Processing - University of Utah

Function Representation

Linear function:

Rewrite as:

Provides intuitive description of linear

functions:

•Angles

•Shifts

How to do this for generic functions?

bmxxf )(

bxf )tan()(

yxm /

Page 4: Fourier Transform in Image Processing - University of Utah

Basis Decomposition

• Write a function as a weighted sum of

basis functions

• What is a good set of basis functions?

• How do you determine the weights?

)()( xBwxf ii

Page 5: Fourier Transform in Image Processing - University of Utah

Sine Waves

• Use sine waves of different frequencies

as basis functions?

Page 6: Fourier Transform in Image Processing - University of Utah

Limitation of Sines

• Sines are odd / anti-symmetric:

• Sine basis cannot create even

functions:

Page 7: Fourier Transform in Image Processing - University of Utah

Limitation of Cosines

• Cosines are even / symmetric functions:

• Cosine basis cannot create odd

functions:

Page 8: Fourier Transform in Image Processing - University of Utah

Combine Cosines and Sines

• Allow creation of both even and odd

functions with different combinations: Odd Even

Page 9: Fourier Transform in Image Processing - University of Utah

Why Sines and Cosines?

• Represent functions as a combination of

basis with different frequencies

• Intuitive description of signals / images:

– how much high frequency content?

– what do the low freq. content look like?

• Image processing “language”:

– remove noise by reducing high freq content

– explains sampling / perception phenomena

Page 10: Fourier Transform in Image Processing - University of Utah

The Fourier Transform

Page 11: Fourier Transform in Image Processing - University of Utah

Reminder: Euler’s Identity

• From calculus

• j is the imaginary part of a complex

number

xjxe sincos jx

Page 12: Fourier Transform in Image Processing - University of Utah

Fourier Transform

• Forward, mapping to frequency domain:

• Backward, inverse mapping to time

domain:

+

Page 13: Fourier Transform in Image Processing - University of Utah

Space and Frequency

Page 14: Fourier Transform in Image Processing - University of Utah

Fourier Series

• Projection or change of basis

• Coordinates in Fourier basis:

• Rewrite f as:

Page 15: Fourier Transform in Image Processing - University of Utah

Example: Step Function

Step function as sum of infinite sine waves

Page 16: Fourier Transform in Image Processing - University of Utah

Discrete Fourier Transform

Page 17: Fourier Transform in Image Processing - University of Utah

Fourier Basis

• Why Fourier basis?

– Can represent integrable functions with

finite support

• Also

– Orthonormal in [-pi, pi]

– Periodic signals with different frequencies

– Continuous, differentiable basis

Page 18: Fourier Transform in Image Processing - University of Utah

FT Properties

Page 19: Fourier Transform in Image Processing - University of Utah

Common Transform Pairs

Dirac delta - constant

Page 20: Fourier Transform in Image Processing - University of Utah

Common Transform Pairs

Rectangle – sinc

sinc(x) = sin(x) / x

Page 21: Fourier Transform in Image Processing - University of Utah

Common Transform Pairs

Two symmetric Diracs - cosine

Page 22: Fourier Transform in Image Processing - University of Utah

Common Transform Pairs

Comb – comb (inverse width)

Page 23: Fourier Transform in Image Processing - University of Utah

Common Transform Pairs

Gaussian – Gaussian (inverse variance)

Page 24: Fourier Transform in Image Processing - University of Utah

Common Transform Pairs

Summary

Page 25: Fourier Transform in Image Processing - University of Utah

Quiz

What is the FT of a triangle function?

Hint: how do you get triangle function from the

functions shown so far?

Page 26: Fourier Transform in Image Processing - University of Utah

Answer

Triangle = box convolved with box

So its FT is sinc * sinc

Page 27: Fourier Transform in Image Processing - University of Utah

Quiz

• What is the FT?

• Hint: use FT properties and express as

functions with known transforms

Page 28: Fourier Transform in Image Processing - University of Utah

Answer

f(x) = Π(x /4) – Λ(x /2) + .5Λ(x)

FT is linear, so

F(w) = 4sinc(4w) - 2sinc2(2w) + .5sinc2(w)

Page 29: Fourier Transform in Image Processing - University of Utah

Fourier Transform of Images

Page 30: Fourier Transform in Image Processing - University of Utah

• Forward transform:

• Backward transform:

• Forward transform to freq. yields

complex values (magnitude and phase):

2D Fourier Transform

Page 31: Fourier Transform in Image Processing - University of Utah

2D Fourier Transform

Page 32: Fourier Transform in Image Processing - University of Utah

Fourier Spectrum

Fourier spectrum

Origin in corners

Retiled with origin

In center

Log of spectrum

Image

Page 33: Fourier Transform in Image Processing - University of Utah

Fourier Spectrum –

Translation and Rotation

Page 34: Fourier Transform in Image Processing - University of Utah

Phase vs Spectrum

Image Reconstruction from

phase map

Reconstruction from

spectrum

Page 35: Fourier Transform in Image Processing - University of Utah

u

v

Image Fourier Space

Page 36: Fourier Transform in Image Processing - University of Utah

10 % 5 % 20 % 50 %

Page 37: Fourier Transform in Image Processing - University of Utah

Fourier Spectrum Demo

http://bigwww.epfl.ch/demo/basisfft/demo.html

Page 38: Fourier Transform in Image Processing - University of Utah

Filtering Using FT and Inverse

X

Page 39: Fourier Transform in Image Processing - University of Utah

Low-Pass Filter • Reduce/eliminate high frequencies

• Applications

– Noise reduction

• uncorrelated noise is broad band

• Images have sprectrum that focus on low

frequencies

86%

88%

90%

92%

94%

96%

98%

100%

0% 10% 20% 30% 40% 50% 60% 70% 80%

Page 40: Fourier Transform in Image Processing - University of Utah

Ideal LP Filter – Box, Rect

Cutoff freq Ringing – Gibbs phenomenon

Page 41: Fourier Transform in Image Processing - University of Utah

Extending Filters to 2D (or

higher)

• Two options

– Separable

• H(s) -> H(u)H(v)

• Easy, analysis

– Rotate

• H(s) -> H((u2 + v2)1/2)

• Rotationally invariant

Page 42: Fourier Transform in Image Processing - University of Utah

Ideal LP Filter – Box, Rect

Page 43: Fourier Transform in Image Processing - University of Utah

Ideal Low-Pass

Rectangle With Cutoff of 2/3

Image Filtered Filtered

+

Histogram Equalized

Page 44: Fourier Transform in Image Processing - University of Utah

Ideal LP – 1/3

Page 45: Fourier Transform in Image Processing - University of Utah

Ideal LP – 2/3

Page 46: Fourier Transform in Image Processing - University of Utah

Butterworth Filter

Control of cutoff and slope

Can control ringing

Page 47: Fourier Transform in Image Processing - University of Utah

Butterworth - 1/3

Page 48: Fourier Transform in Image Processing - University of Utah

Butterworth vs Ideal LP

Page 49: Fourier Transform in Image Processing - University of Utah

Butterworth – 2/3

Page 50: Fourier Transform in Image Processing - University of Utah

Gaussian LP Filtering Ideal LPF Butterworth LPF Gaussian LPF

F1

F2

Page 51: Fourier Transform in Image Processing - University of Utah

High Pass Filtering

• HP = 1 - LP

– All the same filters as HP apply

• Applications

– Visualization of high-freq data (accentuate)

• High boost filtering

– HB = (1- a) + a(1 - LP) = 1 - a*LP

Page 52: Fourier Transform in Image Processing - University of Utah

High-Pass Filters

Page 53: Fourier Transform in Image Processing - University of Utah

High-Pass Filters in Spatial

Domain

Page 54: Fourier Transform in Image Processing - University of Utah

High-Pass Filtering with IHPF

Page 55: Fourier Transform in Image Processing - University of Utah

BHPF

Page 56: Fourier Transform in Image Processing - University of Utah

GHPF

Page 57: Fourier Transform in Image Processing - University of Utah

HP, HB, HE

Page 58: Fourier Transform in Image Processing - University of Utah

High Boost with GLPF

Page 59: Fourier Transform in Image Processing - University of Utah

High-Boost Filtering

Page 60: Fourier Transform in Image Processing - University of Utah

Band-Pass Filters

• Shift LP filter in Fourier domain by

convolution with delta

LP

BP Typically 2-3 parameters

-Width

-Slope

-Band value

Page 61: Fourier Transform in Image Processing - University of Utah

Band Pass - Two Dimensions

• Two strategies

– Rotate

• Radially symmetric

– Translate in 2D

• Oriented filters

• Note:

– Convolution with delta-pair in FD is

multiplication with cosine in spatial domain

Page 62: Fourier Transform in Image Processing - University of Utah

Band Bass Filtering

Page 63: Fourier Transform in Image Processing - University of Utah

SEM Image and Spectrum

Page 64: Fourier Transform in Image Processing - University of Utah

Band-Pass Filter

Page 65: Fourier Transform in Image Processing - University of Utah

Radial Band Pass/Reject

Page 66: Fourier Transform in Image Processing - University of Utah

Band Reject Filtering

Page 67: Fourier Transform in Image Processing - University of Utah

Band Reject Filtering

Page 68: Fourier Transform in Image Processing - University of Utah

Band Reject Filtering

Page 69: Fourier Transform in Image Processing - University of Utah

Aliasing

Page 70: Fourier Transform in Image Processing - University of Utah

Discrete Sampling and

Aliasing • Digital signals and images are discrete

representations of the real world

– Which is continuous

• What happens to signals/images when we

sample them?

– Can we quantify the effects?

– Can we understand the artifacts and can we limit

them?

– Can we reconstruct the original image from the

discrete data?

Page 71: Fourier Transform in Image Processing - University of Utah

Sampling and Aliasing

• Given the sampling rate, CAN NOT

distinguish the two functions

• High freq can appear as low freq

Page 72: Fourier Transform in Image Processing - University of Utah

Ideal Solution: More Samples

• Faster sampling rate allows us to distinguish

the two signals

• Not always practical: hardware cost, longer

scan time

Page 73: Fourier Transform in Image Processing - University of Utah

A Mathematical Model of Discrete

Samples Delta functional

Shah functional

Page 74: Fourier Transform in Image Processing - University of Utah

A Mathematical Model of Discrete

Samples

Discrete signal

Samples from continuous function

Representation as a function of t

• Multiplication of f(t) with Shah

• Goal

– To be able to do a continuous Fourier

transform on a signal before and after

sampling

Page 75: Fourier Transform in Image Processing - University of Utah

Fourier Series of A Shah

Functional

u

Page 76: Fourier Transform in Image Processing - University of Utah

Fourier Transform of A Discrete

Sampling

u

Page 77: Fourier Transform in Image Processing - University of Utah

Fourier Transform of A Discrete

Sampling

u

Energy from higher

freqs gets folded back

down into lower freqs –

Aliasing

Frequencies get

mixed. The

original signal is

not recoverable.

Page 78: Fourier Transform in Image Processing - University of Utah

What if F(u) is Narrower in the Fourier

Domain?

u

• No aliasing!

• How could we recover the original

signal?

Page 79: Fourier Transform in Image Processing - University of Utah

What Comes Out of This

Model

• Sampling criterion for complete

recovery

• An understanding of the effects of

sampling

– Aliasing and how to avoid it

• Reconstruction of signals from discrete

samples

Page 80: Fourier Transform in Image Processing - University of Utah

Shannon Sampling Theorem

• Assuming a signal that is band limited:

• Given set of samples from that signal

• Samples can be used to generate the

original signal

– Samples and continuous signal are

equivalent

Page 81: Fourier Transform in Image Processing - University of Utah

Sampling Theorem

• Quantifies the amount of information in

a signal

– Discrete signal contains limited frequencies

– Band-limited signals contain no more

information then their discrete equivalents

• Reconstruction by cutting away the

repeated signals in the Fourier domain

– Convolution with sinc function in

space/time

Page 82: Fourier Transform in Image Processing - University of Utah

Reconstruction

• Convolution with sinc function

Page 83: Fourier Transform in Image Processing - University of Utah

Sinc Interpolation Issues

• Must functions are not band limited

• Forcing functions to be band-limited can

cause artifacts (ringing)

f(t) |F(s)|

Page 84: Fourier Transform in Image Processing - University of Utah

Sinc Interpolation Issues

Ringing - Gibbs phenomenon

Other issues:

Sinc is infinite - must be truncated

Page 85: Fourier Transform in Image Processing - University of Utah

Aliasing

• Reminder: high frequencies appear as

low frequencies when undersampled

Page 86: Fourier Transform in Image Processing - University of Utah

Aliasing

16 pixels 8 pixels

0.9174

pixels

0.4798

pixels

Page 87: Fourier Transform in Image Processing - University of Utah

Aliasing

Aliasing in digital videos

Page 88: Fourier Transform in Image Processing - University of Utah

Overcoming Aliasing

• Filter data prior to sampling

– Ideally - band limit the data (conv with sinc

function)

– In practice - limit effects with fuzzy/soft low

pass

Page 89: Fourier Transform in Image Processing - University of Utah

Antialiasing in Graphics

• Screen resolution produces aliasing on

underlying geometry

Multiple high-res

samples get averaged

to create one screen

sample

Page 90: Fourier Transform in Image Processing - University of Utah

Antialiasing

Page 91: Fourier Transform in Image Processing - University of Utah

Interpolation as Convolution

• Any discrete set of samples can be considered as a functional

• Any linear interpolant can be considered as a convolution

– Nearest neighbor - rect(t)

– Linear - tri(t)

Page 92: Fourier Transform in Image Processing - University of Utah

Convolution-Based Interpolation

• Can be studied in terms of Fourier Domain

• Issues

– Pass energy (=1) in band

– Low energy out of band

– Reduce hard cut off (Gibbs, ringing)

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

1.2

-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6

Page 93: Fourier Transform in Image Processing - University of Utah

Fast Fourier Transform

With slides from Richard

Stern, CMU

Page 94: Fourier Transform in Image Processing - University of Utah

DFT

• Ordinary DFT is O(N2)

• DFT is slow for large images

• Exploit periodicity and symmetricity

• Fast FT is O(N log N)

• FFT can be faster than convolution

Page 95: Fourier Transform in Image Processing - University of Utah

Fast Fourier Transform

• Divide and conquer algorithm

• Gauss ~1805

• Cooley & Tukey 1965

• For N = 2K

Page 96: Fourier Transform in Image Processing - University of Utah

The Cooley-Tukey Algorithm

• Consider the DFT algorithm for an integer power of 2,

• Create separate sums for even and odd values of n:

• Letting for n even and for n odd, we

obtain

N 2

X[k]

n0

N1

x[n]WNnk

n0

N1

x[n]e j2nk /N ; WN e j2 /N

X[k] x[n]WNnk

n even

x[n]WNnk

n odd

n 2r n 2r 1

X[k] x[2r]WN2rk

r0

N / 2 1

x[2r 1]WN2r1 k

r0

N /2 1

Page 97: Fourier Transform in Image Processing - University of Utah

The Cooley-Tukey Algorithm

• Splitting indices in time, we have obtained

• But and

So …

N/2-point DFT of x[2r] N/2-point DFT of x[2r+1]

X[k] x[2r]WN2rk

r0

N / 2 1

x[2r 1]WN2r1 k

r0

N /2 1

WN2 e j22 / N e j2 /(N / 2) WN / 2 WN

2rkWNk WN

kWN / 2rk

X[k]

n0

(N/ 2)1

x[2r]WN /2rk WN

k

n0

(N/ 2)1

x[2r 1]WN / 2rk

Page 98: Fourier Transform in Image Processing - University of Utah

Example: N=8

• Divide and reuse

Page 99: Fourier Transform in Image Processing - University of Utah

Example: N=8, Upper Part

• Continue to divide and reuse

Page 100: Fourier Transform in Image Processing - University of Utah

Two-Point FFT

• The expression for the 2-point DFT is:

• Evaluating for we obtain

which in signal flowgraph notation looks like ...

X[k]

n0

1

x[n]W2nk

n0

1

x[n]e j2nk / 2

k 0,1

X[0] x[0] x[1]

X[1] x[0] e j21/ 2x[1] x[0] x[1]

This topology is referred to as the

basic butterfly

Page 101: Fourier Transform in Image Processing - University of Utah

Modern FFT

• FFTW

http://www.fftw.org/