BBM 413 Fundamentals of Thinking images in terms of frequency. - - PowerPoint PPT Presentation

bbm 413 fundamentals of
SMART_READER_LITE
LIVE PREVIEW

BBM 413 Fundamentals of Thinking images in terms of frequency. - - PowerPoint PPT Presentation

Review Frequency Domain Techniques BBM 413 Fundamentals of Thinking images in terms of frequency. Image Processing Treat images as infinite-size, continuous periodic ...& functions. Erkut Erdem )& Dept. of Computer


slide-1
SLIDE 1

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 images as infinite-size, continuous periodic

functions.

=&

)&

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

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

  • 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-2
SLIDE 2

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 π

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

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

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-3
SLIDE 3

Review - Filtering in frequency domain

FFT FFT Inverse FFT

=

Slide credit: D. Hoiem

Today

  • Sampling
  • Gabor wavelets, Steerable filters

Today

  • Sampling
  • Gabor wavelets, Steerable filters

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

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

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

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

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-5
SLIDE 5

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

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!

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

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:

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

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-6
SLIDE 6

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

Slide credit: D. Hoiem

Subsampling by a factor of 2 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

  • 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

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-7
SLIDE 7

More examples

Check out Moire patterns

  • n the web.

Slide credit: A. Farhadi

Aliasing in video

Slide credit: S. Seitz

Aliasing in graphics

Slide credit: A. Efros

Sampling and aliasing

Slide credit: D. Hoiem

slide-8
SLIDE 8

( ) ( ) ( ) ( ) ( )

∞ −∞ =

− = =

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

  • 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

2D example

Good sampling Bad sampling

Slide credit: N. Kumar

slide-9
SLIDE 9

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

Preventing aliasing

  • Introduce lowpass filters:

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

Slide credit: S. Marschner

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

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-10
SLIDE 10

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

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

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

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-11
SLIDE 11

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.

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

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:

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-12
SLIDE 12

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

Anti-aliasing

Slide credit: Forsyth and Ponce

Subsampling without pre-filtering

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

Slide credit: S. Seitz

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

Subsampling with Gaussian pre-filtering

Slide credit: S. Seitz

slide-13
SLIDE 13

1000 pixel width

[Philip Greenspun]

Slide credit: S. Marschner

250 pixel width by dropping pixels gaussian filter

[Philip Greenspun]

Slide credit: S. Marschner

Up-sampling

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

Slide credit: A. Farhadi

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-14
SLIDE 14

Up-sampling Methods

Slide credit: A. Farhadi

Up-sampling

Nearest neighbor Bilinear Bicubic

Slide credit: A. Farhadi

Up-sampling

Nearest neighbor Bilinear Bicubic

Slide credit: A. Farhadi

Today

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

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

Phase Caries More Information

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

Slide credit: S. Thrun

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

Analyzing local image structures

T

  • o much

T

  • o little

Slide credit: B. Freeman and A. Torralba

slide-16
SLIDE 16

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 ฀

  • 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

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

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-17
SLIDE 17

even

  • dd

66

66

John Daugman, 1988

Slide credit: B. Freeman and A. Torralba

+

(.)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

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-18
SLIDE 18

edge energy response to an edge

Slide credit: B. Freeman and A. Torralba

Quadrature filter pairs

line energy response to a line

Quadrature filter pairs

Slide credit: B. Freeman and A. Torralba

How quadrature pair filters work

Slide credit: B. Freeman and A. Torralba

How quadrature pair filters work

+

(.)2 (.)2

Slide credit: B. Freeman and A. Torralba

slide-19
SLIDE 19

  • 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

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

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

Steerable filters

Slide credit: B. Freeman and A. Torralba

slide-20
SLIDE 20

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

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

Summary

  • Sampling
  • Gabor wavelets, Steerable filters

Next week

  • Image pyramids