BBM 413 Fundamentals of Image Processing Erkut Erdem Dept. of - - PowerPoint PPT Presentation

bbm 413 fundamentals of image processing
SMART_READER_LITE
LIVE PREVIEW

BBM 413 Fundamentals of Image Processing Erkut Erdem Dept. of - - PowerPoint PPT Presentation

BBM 413 Fundamentals of Image Processing Erkut Erdem Dept. of Computer Engineering Hacettepe University Frequency Domain Techniques Part 2 Review Frequency Domain Techniques Thinking images in terms of frequency. Treat


slide-1
SLIDE 1

BBM 413 Fundamentals of Image Processing

Erkut Erdem

  • Dept. of Computer Engineering

Hacettepe University

Frequency Domain Techniques – Part 2

slide-2
SLIDE 2

Review – Frequency Domain Techniques

  • Thinking images in terms of frequency.
  • Treat images as infinite-size, continuous periodic

functions.

=&

)&

=& ...& ...& ...& ...&

slide-3
SLIDE 3

Review - Fourier Transform

We want to understand the frequency w of our signal. So, let’s reparametrize the signal by w instead of x:

) +φ ωx Asin(

f( f(x) F( F(w)

Fourier Transform

F( F(w) f( f(x)

Inverse Fourier Transform For every w from 0 to inf, F(w) holds the amplitude A and phase f of the corresponding sine

  • How can F hold both? Complex number trick!

) ( ) ( ) ( ω ω ω iI R F + =

2 2

) ( ) ( ω ω I R A + ± =

) ( ) ( tan 1 ω ω φ R I

=

We can always go back:

Slide credit: A. Efros

slide-4
SLIDE 4
  • 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

2 2

) ( ) ( ω ω I R A + ± =

) ( ) ( tan 1 ω ω φ R I

=

Amplitude: Phase:

Review - Fourier Transform

slide-5
SLIDE 5

Slide credit: B. Freeman and A. Torralba

Review - Discrete Fourier transform

  • Forward transform
  • Inverse transform

Euler’s definition of eiθ

u, v : the transform or frequency variables x, y : the spatial or image variables

F(u,v) = 1 MN f (x, y)e− j2π (ux/M+vy/N )

y=0 N−1

x=0 M−1

for u = 0,1,2,..., M −1,v = 0,1,2,..., N −1

1 ,..., 2 , 1 , , 1 ,..., 2 , 1 , for ) , ( ) , (

1 1 ) / / ( 2

− = − = = ∑∑

− = − = +

N y M x e v u F y x f

M u N v N vy M ux j π

slide-6
SLIDE 6

Review - The Fourier Transform

  • Represent function on a new basis

– Think of functions as vectors, with many components – We now apply a linear transformation to transform the basis

  • dot product with each basis element
  • In the expression, u and v select the basis

element, so a function of x and y becomes a function of u and v

  • basis elements have the form e−i2π ux+vy

( )

Slide credit: S. Thrun

slide-7
SLIDE 7

Horizontal

  • rientation

Vertical orientation

45 deg.

fmax

fx in cycles/image Low spatial frequencies High spatial frequencies

Slide credit: B. Freeman and A. Torralba

Review - The Fourier Transform

Log power spectrum

slide-8
SLIDE 8

Review - The Convolution Theorem

  • 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!

] F[ ] F[ ] F[ h g h g = ∗

] [ F ] [ F ] [ F

1 1 1

h g gh

− − −

∗ =

Slide credit: A. Efros

slide-9
SLIDE 9

Review - Filtering in frequency domain

FFT FFT Inverse FFT

=

Slide credit: D. Hoiem

slide-10
SLIDE 10

Today

  • Sampling
  • Gabor wavelets, Steerable filters
slide-11
SLIDE 11

Today

  • Sampling
  • Gabor wavelets, Steerable filters
slide-12
SLIDE 12

Why does a lower resolution image still make sense to us? What do we lose?

Image: http://www.flickr.com/photos/igorms/136916757/

Sampling

Slide credit: D. Hoiem

slide-13
SLIDE 13

Sampled representations

  • How to store and compute with continuous functions?
  • Common scheme for representation: samples

– write down the function’s values at many points

Slide credit: S. Marschner

slide-14
SLIDE 14

Reconstruction

  • Making samples back into a continuous function

– for output (need realizable method) – for analysis or processing (need mathematical method) – amounts to “guessing” what the function did in between

Slide credit: S. Marschner

slide-15
SLIDE 15

Sampling in digital audio

  • Recording: sound to analog to samples to disc
  • Playback: disc to samples to analog to sound again

– how can we be sure we are filling in the gaps correctly?

Slide credit: S. Marschner

slide-16
SLIDE 16

Continuous signal: Shah function (Impulse train):

( )

x f x

Sampled function:

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

n s

nx x x f x s x f x f δ

( )

x s

x

x

( ) ( )

∞ −∞ =

− =

n

nx x x s δ

(Real world signal) (What the image measures)

Sampling Theorem

Slide credit: S. Narasimhan

slide-17
SLIDE 17

Sampled function:

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

n s

nx x x f x s x f x f δ F

S u

( ) = F u ( )∗S u ( ) = F u ( )∗ 1

x0 δ u − n x0 $ % & ' ( )

n=−∞ ∞

( )

u F

max

u

A

u

Sampling frequency

1 x

Slide credit: S. Narasimhan

Sampling Theorem

slide-18
SLIDE 18

angular frequency ( )

iux

e−

Note that these are derived using Slide credit: S. Narasimhan

Fourier Transform Pairs

FT of an “impulse train” is an impulse train!

slide-19
SLIDE 19

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

n s

nx x x f x s x f x f δ F

S u

( ) = F u ( )∗S u ( ) = F u ( )∗ 1

x0 δ u − n x0 $ % & ' ( )

n=−∞ ∞

F u

( )

max

u

A

u

Sampling frequency

1 x

*

S u

( )

Slide credit: S. Narasimhan

Sampling Theorem

Sampled function:

slide-20
SLIDE 20

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

n s

nx x x f x s x f x f δ F

S u

( ) = F u ( )∗S u ( ) = F u ( )∗ 1

x0 δ u − n x0 $ % & ' ( )

n=−∞ ∞

( )

u F

max

u

A

u

( )

u FS

max

u

x A 1x

u

Sampling frequency

1 x

Slide credit: S. Narasimhan

Sampling Theorem

Sampled function:

slide-21
SLIDE 21

Throw away every other row and column to create a 1/2 size image

Slide credit: D. Hoiem

Subsampling by a factor of 2

slide-22
SLIDE 22

Undersampling

  • What if we “missed” things between the samples?
  • Simple example: undersampling a sine wave

– unsurprising result: information is lost – surprising result: indistinguishable from lower frequency – also was always indistinguishable from higher frequencies – aliasing: signals “traveling in disguise” as other frequencies

Slide credit: S. Marschner

slide-23
SLIDE 23
  • Sub-sampling may be dangerous….
  • Characteristic errors may appear:

– “Wagon wheels rolling the wrong way in movies” – “Checkerboards disintegrate in ray tracing” – “Striped shirts look funny on color television”

Aliasing problem

Slide credit: D. Forsyth

slide-24
SLIDE 24

Moire patterns in real-world images. Here are comparison images by Dave Etchells of Imaging Resource using the Canon D60 (with an antialias filter) and the Sigma SD-9 (which has no antialias filter). The bands below the fur in the image at right are the kinds of artifacts that appear in images when no antialias filter is used. Sigma chose to eliminate the filter to get more sharpness, but the resulting apparent detail may or may not reflect features in the image.

Slide credit: N. Kumar

slide-25
SLIDE 25

More examples

Check out Moire patterns

  • n the web.

Slide credit: A. Farhadi

slide-26
SLIDE 26

Aliasing in video

Slide credit: S. Seitz

slide-27
SLIDE 27

Aliasing in graphics

Slide credit: A. Efros

slide-28
SLIDE 28

Sampling and aliasing

Slide credit: D. Hoiem

slide-29
SLIDE 29

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

n s

nx x x f x s x f x f δ F

S u

( ) = F u ( )∗S u ( ) = F u ( )∗ 1

x0 δ u − n x0 $ % & ' ( )

n=−∞ ∞

( )

u F

max

u

A

u

( )

u FS

max

u

x A 1x

u

Sampling frequency

1 x

Slide credit: S. Narasimhan

Sampling Theorem

Sampled function:

slide-30
SLIDE 30

Slide credit: S. Narasimhan

Nyquist Frequency

If

max

2 1 x u >

( )

u FS

max

u

x A 1x

u

Aliasing When can we recover from ?

( )

u F

( )

u FS

Only if

max

2 1 x u ≤

(Nyquist Frequency) We can use

( )

! " ! # $ < =

  • therwise

2 1 x u x u C

Then

( ) ( ) ( )

u C u F u F

S

=

( ) ( )

[ ]

u F x f IFT =

and Sampling frequency must be greater than

max

2u

slide-31
SLIDE 31
  • When sampling a signal at discrete intervals, the

sampling frequency must be ≥ 2 × fmax

  • fmax = max frequency of the input signal
  • This will allows to reconstruct the original perfectly

from the sampled version

good bad v v v

Nyquist-Shannon Sampling Theorem

Slide credit: D. Hoiem

slide-32
SLIDE 32

2D example

Good sampling Bad sampling

Slide credit: N. Kumar

slide-33
SLIDE 33

Anti-aliasing

Solutions:

  • Sample more often
  • Get rid of all frequencies that are greater than half the new

sampling frequency

– Will lose information – But it’s better than aliasing – Apply a smoothing filter

Slide credit: D. Hoiem

slide-34
SLIDE 34

Preventing aliasing

  • Introduce lowpass filters:

– remove high frequencies leaving only safe, low frequencies – choose lowest frequency in reconstruction (disambiguate)

Slide credit: S. Marschner

slide-35
SLIDE 35

Impulse Train

  • Define a comb function (impulse train) in 1D as follows

where M is an integer

[ ] [ ]

M k

comb x x kM δ

∞ =−∞

= −

[ ] x x

1

δ

∞ =−∞

= −

2[ ]

comb x x

1

Slide credit: B. K. Gunturk

slide-36
SLIDE 36

Impulse Train in 2D (bed of nails)

  • Fourier Transform of an impulse train is also an impulse train:

( )

δ δ

∞ ∞ ∞ ∞ =−∞ =−∞ =−∞ =−∞

− ⇔ − −

  • ∑ ∑

∑ ∑

( , u ( , ) y

( )

, ( , )

,

M N k l

comb x y x kM y lN δ

∞ ∞ =−∞ =−∞

− −

∑ ∑

  • (

)

1 , ,

k l k l

k l x kM y lN u v MN M N δ δ

∞ ∞ ∞ ∞ =−∞ =−∞ =−∞ =−∞

− ⇔ − −

  • ∑ ∑

∑ ∑

1 1 , ( , ) M N

comb u v

, ( , ) M N

comb x y

( )

δ

∞ ∞ =−∞ =−∞

− −

∑ ∑

  • As the comb samples get further apart,

the spectrum samples get closer together!

Slide credit: B. K. Gunturk

slide-37
SLIDE 37

Impulse Train in 1D

  • Remember:

2( )

comb x x u

1

12 1 2

1 ( ) 2 comb u

1 2 2

( )

ax

  • Remember:

Scaling

( )

ax f

  • a

u F a 1

Slide credit: B. K. Gunturk

slide-38
SLIDE 38

Sampling low frequency signal

x

( ) f x

x

M

( )

M

comb x

u

( ) F u

u

1 M

1 ( ) M

comb u

x

( ) ( )

M

f x comb x

u

1

( )* ( )

M

F u comb u

Multiply: Convolve:

Slide credit: B. K. Gunturk

slide-39
SLIDE 39

Sampling low frequency signal

x

( ) f x

u

( ) F u

u

1

( )* ( )

M

F u comb u

x

( ) ( )

M

f x comb x

W W − M W 1 M

1 2W M >

No “problem” if

Slide credit: B. K. Gunturk

“No problem” if

slide-40
SLIDE 40

Sampling low frequency signal

If there is no overlap, the original signal can be recovered from its samples by low-pass filtering.

u

1

( )* ( )

M

F u comb u

x

( ) ( )

M

f x comb x

M W 1 M 1 2M

Slide credit: B. K. Gunturk

slide-41
SLIDE 41

Sampling high frequency signal

Slide credit: B. K. Gunturk

u

( ) F u

W W −

u

1

( )* ( )

M

F u comb u

( ) ( )

M

f x comb x

W 1 M

Overlap: The high frequency energy is folded over into low

x

( ) f x

Overlap: The high frequency energy is folded over into low

  • frequency. It is “aliasing” as lower

frequency energy. And you cannot fix it once it has happened.

slide-42
SLIDE 42

Sampling high frequency signal

Slide credit: B. K. Gunturk

u

( ) F u

u

[ ]

( )* ( ) ( )

M

f x h x comb x

W W − 1M

Anti-aliasing filter

u

W W −

( )* ( ) f x h x

1 2M

B.K. Gunturk

x

( ) f x

slide-43
SLIDE 43

Sampling high frequency signal

  • Without anti-aliasing filter:
  • With anti-aliasing filter:

Slide credit: B. K. Gunturk

u

[ ]

( )* ( ) ( )

M

f x h x comb x

1 M

■ ■

u

[ ]

1

u

( ) ( )

M

f x comb x

W 1 M

■ ■ With anti-aliasing filter:

slide-44
SLIDE 44

Sampling high frequency signal

u

[ ]

( )* ( ) ( )

M

f x h x comb x

1 M

u

( ) ( )

M

f x comb x

W 1 M

■ Without anti-aliasing filter: ■ With anti-aliasing filter:

B.K. Gunturk

slide-45
SLIDE 45

Algorithm for downsampling by factor of 2

  • 1. Start with image(h, w)
  • 2. Apply low-pass filter

im_blur = imfilter(image, fspecial(‘gaussian’, 7, 1))

  • 3. Sample every other pixel

im_small = im_blur(1:2:end, 1:2:end);

Slide credit: D. Hoiem

slide-46
SLIDE 46

Anti-aliasing

Slide credit: Forsyth and Ponce

slide-47
SLIDE 47

Subsampling without pre-filtering

1/4 (2x zoom) 1/8 (4x zoom) 1/2

Slide credit: S. Seitz

slide-48
SLIDE 48

G 1/4 G 1/8 Gaussian 1/2

Subsampling with Gaussian pre-filtering

Slide credit: S. Seitz

slide-49
SLIDE 49

1000 pixel width

[Philip Greenspun]

Slide credit: S. Marschner

slide-50
SLIDE 50

250 pixel width by dropping pixels gaussian filter

[Philip Greenspun]

Slide credit: S. Marschner

slide-51
SLIDE 51

Up-sampling

How do we compute the values of pixels at fractional positions?

Slide credit: A. Farhadi

slide-52
SLIDE 52

Up-sampling

f (x,y) f (x+1,y) f (x+1,y+1) f (x,y+1) f (x+0.8,y+0.3)

f (x + a, y + b) = (1 - a)(1 - b) f (x, y) + a(1 - b) f (x + 1, y) + (1 - a)b f (x,y + 1) + ab f (x + 1, y + 1) Bilinear sampling: Bicubic sampling fits a higher order function using a larger area of support. How do we compute the values of pixels at fractional positions?

Slide credit: A. Farhadi

slide-53
SLIDE 53

Up-sampling Methods

Slide credit: A. Farhadi

slide-54
SLIDE 54

Up-sampling

Nearest neighbor Bilinear Bicubic

Slide credit: A. Farhadi

slide-55
SLIDE 55

Up-sampling

Nearest neighbor Bilinear Bicubic

Slide credit: A. Farhadi

slide-56
SLIDE 56

Today

  • Sampling
  • Gabor wavelets, Steerable filters
slide-57
SLIDE 57

Fourier Filtering

Images from Steve Lehar http://cns-alumni.bu.edu/~sleharAn Intuitive Explanation of Fourier Theory Fourier Amplitude

Multiply by a filter in the frequency domain => convolve with the filter in spatial domain.

Slide credit: S. Thrun

slide-58
SLIDE 58

Phase Caries More Information

Magnitude and Phase: Raw Images: Reconstruct (inverse FFT) mixing the magnitude and phase images Phase “Wins”

Slide credit: S. Thrun

slide-59
SLIDE 59

What is a good representation for image analysis?

  • Fourier transform domain tells you “what” (textural

properties), but not “where”.

  • Pixel domain representation tells you “where” (pixel

location), but not “what”.

  • Want an image representation that gives you a local

description of image events—what is happening where.

Slide credit: B. Freeman and A. Torralba

slide-60
SLIDE 60

Analyzing local image structures

T

  • o much

T

  • o little

Slide credit: B. Freeman and A. Torralba

slide-61
SLIDE 61

Probably ¡still ¡too ¡little… …but ¡hard ¡enough ¡for ¡now

฀ h(x,y) e

x 2 y 2 2 2

1

The image through the Gaussian window

T

  • o much

T

  • o little

Probably still too little... ...but hard enough for now

Slide credit: B. Freeman and A. Torralba

slide-62
SLIDE 62

  • r wavelet:

฀ (x,y) e

x 2 y 2 2 2 e j2u0x

  • Analysis of local frequency

Fourier basis: Gabor wavelet: We can look at the real and imaginary parts:

฀ h(x,y;x0,y0) e

xxo

  • 2 yyo
  • 2

2 2

(x0, y0)

e j2u0x

c(x,y) e

x 2 y 2 2 2 cos 2u0x

s(x,y) e

x 2 y 2 2 2 sin 2u0x

  • Slide credit: B. Freeman and A. Torralba
slide-63
SLIDE 63

Gabor wavelets

ψc(x,y) = e

− x 2 +y 2 2σ 2 cos 2πu0x

( )

u0=0

ψs(x,y) = e

− x 2 +y 2 2σ 2 sin 2πu0x

( )

U0=0.1 U0=0.2

Slide credit: B. Freeman and A. Torralba

slide-64
SLIDE 64

Gabor filters at different scales and spatial frequencies T

  • p row shows anti-symmetric

(or odd) filters; these are good for detecting

  • dd-phase structures like edges.

Bottom row shows the symmetric (or even) filters, good for detecting line phase contours.

Gabor filters

Slide credit: B. Freeman and A. Torralba

slide-65
SLIDE 65

even

  • dd
slide-66
SLIDE 66

66

66

John Daugman, 1988

Slide credit: B. Freeman and A. Torralba

slide-67
SLIDE 67

+

(.)2 (.)2

Quadrature filter pairs

  • A quadrature filter is a complex filter whose real part is related to its

imaginary part via a Hilbert transform along a particular axis through the

  • rigin

Gabor wavelet:

  • , ) e

x 2 y 2 2 2 e j2u0x

฀ (x,y) e

  • Slide credit:
  • B. Freeman & A. Torralba
slide-68
SLIDE 68

Quadrature filter pairs

Contrast invariance! (same energy response for white dot on black background as for a black dot on a white background).

Slide credit: B. Freeman and A. Torralba

+

(.)2 (.)2

slide-69
SLIDE 69

edge energy response to an edge

Slide credit: B. Freeman and A. Torralba

Quadrature filter pairs

slide-70
SLIDE 70

line energy response to a line

Quadrature filter pairs

Slide credit: B. Freeman and A. Torralba

slide-71
SLIDE 71

How quadrature pair filters work

Slide credit: B. Freeman and A. Torralba

slide-72
SLIDE 72

How quadrature pair filters work

+

(.)2 (.)2

Slide credit: B. Freeman and A. Torralba

slide-73
SLIDE 73

  • y' sin()x cos()y

n al Imag al Imag

Oriented Filters

  • Gabor wavelet:
  • Tuning filter orientation:

  • , ) e

x 2 y 2 2 2 e j2u0x

฀ (x,y) e

x' cos()x sin()y y' sin()x cos()y Real Imag Real Imag Space Fourier Domain

Slide credit: B. Freeman and A. Torralba

slide-74
SLIDE 74

Simple example

“Steerability”-- the ability to synthesize a filter of any orientation from a linear combination of filters at fixed orientations.

Filter Set:

0o 90o Synthesized 30o

Response:

Raw Image

Taken from:

  • W. Freeman, T. Adelson,

“The Design and Use of Sterrable Filters”, IEEE

  • Trans. Patt, Anal. and

Machine Intell., vol 13, #9, pp 891-900, Sept 1991

Slide credit: B. Freeman and A. Torralba

slide-75
SLIDE 75

Steerable filters

Derivatives of a Gaussian: An arbitrary orientation can be computed as a linear combination of those two basis functions: The representation is “shiftable” on orientation: We can interpolate any

  • ther orientation from a finite set of basis functions.

฀ hx(x,y) h(x,y) x

  • x

2 4 e

x 2 y 2 2 2

  • )

(x,y

  • The ¡representation ¡is ¡“shiftable” ¡on ¡orientation: ¡We ¡can ¡interpolate ¡any ¡other

hy(x,y) h(x,y) y

  • y

2 4 e

x 2 y 2 2 2

  • ,y)

The ¡representation ¡is ¡“shiftable” ¡on ¡orientation: ¡We ¡can ¡interpolate ¡any ¡other

h(x,y) cos()hx(x,y) sin()hy(x,y)

The ¡representation ¡is ¡“shiftable” ¡on ¡orientation: ¡We ¡can ¡interpolate ¡any ¡other

  • cos( )

+sin( ) =

  • The ¡representation ¡is ¡“shiftable” ¡on ¡orientation: ¡We ¡can ¡interpolate ¡any ¡other

Slide credit: B. Freeman and A. Torralba

Freeman & Adelson, 1992

slide-76
SLIDE 76

Steerable filters

Slide credit: B. Freeman and A. Torralba

slide-77
SLIDE 77

Local image representations

V1 sketch: hypercolumns A pixel [r,g,b] An image patch

J.G.Daugman, “Two dimensional spectral analysis of cortical receptive field profiles,” Vision Res., vol.20.pp.847-856.1980

  • L. Wiskott, J-M. Fellous, N. Kuiger, C. Malsburg, “Face Recognition by Elastic Bunch Graph Matching”, IEEE Transactions on Pattern Analysis and Machine

Intelligence, vol.19(7), July 1997, pp. 775-779.

Gabor filter pair in quadrature Gabor jet

Slide credit: B. Freeman and A. Torralba

slide-78
SLIDE 78

Gabor Filter Bank

  • r = [12 6 3 2];
  • r = [4 4 4 4];

Not for image reconstruction. It does NOT cover the entire space!

Slide credit: B. Freeman and A. Torralba

slide-79
SLIDE 79

Summary

  • Sampling
  • Gabor wavelets, Steerable filters
slide-80
SLIDE 80

Next week

  • Image pyramids