Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline •...

36
Convolution Fourier Convolution Outline Review linear imaging model Instrument response function vs Point spread function Convolution integrals • Fourier Convolution • Reciprocal space and the Modulation transfer function Optical transfer function Examples of convolutions Fourier filtering Deconvolution Example from imaging lab • Optimal inverse filters and noise 22.058 - lecture 4, Convolution and Fourier Convolution

Transcript of Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline •...

Page 1: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution

Fourier Convolution

Outline • Review linear imaging model • Instrument response function vs Point spread function • Convolution integrals • Fourier Convolution • Reciprocal space and the Modulation transfer function • Optical transfer function • Examples of convolutions • Fourier filtering • Deconvolution • Example from imaging lab • Optimal inverse filters and noise

22.058 - lecture 4, Convolution and Fourier Convolution

Page 2: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Instrument Response Function The Instrument Response Function is a conditional mapping, the form of the map depends on the point that is being mapped.

IRF(x, y | x0, y0 ) = S{δ(x − x0 )δ(y − y0 )}

This is often given the symbol h(r|r’).

Of course we want the entire output from the whole object function, ∞ ∞

E( x, y) = ∫∫ ∫∫ I(x, y)S{δ( x − x0 )δ(y − y0 )}dxdydx0dy0 −∞ −∞

∞ ∞

E( x, y) = ∫∫ ∫∫ I(x, y)IRF(x, y | x0, y0 )dxdydx0dy0 −∞ −∞

and so we need to know the IRF at all points.

22.058 - lecture 4, Convolution and Fourier Convolution

Page 3: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Space Invariance

Now in addition to every point being mapped independently onto the detector, imaging that the form of the mapping does not vary over space (is independent of r0). Such a mapping is called isoplantic. For this case the instrument response function is not conditional.

IRF(x, y | x0, y0 ) = PSF(x − x0, y − y0 )

The Point Spread Function (PSF) is a spatially invariant approximation of the IRF.

22.058 - lecture 4, Convolution and Fourier Convolution

Page 4: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Space Invariance Since the Point Spread Function describes the same blurring over the entire sample,

IRF(x, y | x0, y0 ) ⇒ PSF(x − x0, y − y0 )

The image may be described as a convolution,

E( x, y) = ∫∫ I (x0, y0 )PSF(x − x0, y − y0 )dx0dy0 −∞

or,

Image(x, y) = Object (x, y) ⊗ PSF( x, y) + noise

22.058 - lecture 4, Convolution and Fourier Convolution

Page 5: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Integrals Let’s look at some examples of convolution integrals,

∞ f (x) = g( x) ⊗ h( x) = ∫ g(x ')h( x − x' )dx'

−∞So there are four steps in calculating a convolution integral:

#1. Fold h(x’) about the line x’=0 #2. Displace h(x’) by x #3. Multiply h(x-x’) * g(x’) #4. Integrate

22.058 - lecture 4, Convolution and Fourier Convolution

Page 6: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Integrals Consider the following two functions:

#2. Displace h(x’) by x x

#1. Fold h(x’) about the line x’=0

22.058 - lecture 4, Convolution and Fourier Convolution

Page 7: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Integrals

22.058 - lecture 4, Convolution and Fourier Convolution

Page 8: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Integrals Consider the following two functions:

22.058 - lecture 4, Convolution and Fourier Convolution

Page 9: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Integrals

22.058 - lecture 4, Convolution and Fourier Convolution

Page 10: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Some Properties of the Convolution

commutative:

f ⊗ g = g ⊗ f

associative:

f ⊗ (g ⊗ h) = ( f ⊗ g) ⊗ h

multiple convolutions can be carried out in any order.

distributive:

f ⊗ (g + h) = f ⊗ g + f ⊗ h

22.058 - lecture 4, Convolution and Fourier Convolution

Page 11: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Integral

Recall that we defined the convolution integral as, ∞

f ⊗ g = ∫ f (x)g(x '−x)dx −∞

One of the most central results of Fourier Theory is the convolution theorem (also called the Wiener-Khitchine theorem.

ℑ{ f ⊗ g}= F(k) ⋅ G(k)

where, f (x) ⇔ F(k) g(x) ⇔ G(k)

22.058 - lecture 4, Convolution and Fourier Convolution

Page 12: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Theorem

ℑ{ f ⊗ g}= F(k) ⋅ G(k)

In other words, convolution in real space is equivalent to multiplication in reciprocal space.

22.058 - lecture 4, Convolution and Fourier Convolution

Page 13: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Convolution Integral Example

We saw previously that the convolution of two top-hat functions (with the same widths) is a triangle function. Given this, what is the Fourier transform of the triangle function?

=

?

-3 -2 -1 1 2 3

5

10

15

-3 -2 -1 1 2 3

5

10

15

22.058 - lecture 4, Convolution and Fourier Convolution

Page 14: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Proof of the Convolution Theorem

∞ f ⊗ g = ∫ f (x)g(x '−x)dx

−∞

The inverse FT of f(x) is,

1 ∞ F(k )eikxdkf (x) =

2 π−∫∞

and the FT of the shifted g(x), that is g(x’-x)

g(x '−x) = 1 ∞∫ G(k ' )eik '(x '−x )dk '

2π −∞

22.058 - lecture 4, Convolution and Fourier Convolution

Page 15: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Proof of the Convolution Theorem

So we can rewrite the convolution integral,∞

f ⊗ g = ∫ f (x)g(x '−x)dx −∞ as,

∞ ∞ ∞ f ⊗ g =

1 ∫ dx ∫ F(k)eikxdk ∫ G(k ' )eik '( x'− x )dk ' 4π2

−∞ −∞ −∞

change the order of integration and extract a delta function,

∞ f ⊗ g =

1 ∞∫ dkF(k ) ∫ dk 'G(k ')eik 'x' 1 ∞

∫ eix(k −k ')dx2π −∞ −∞ 2π−∞1442443

δ(k−k ')

22.058 - lecture 4, Convolution and Fourier Convolution

Page 16: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Proof of the Convolution Theorem ∞

f ⊗ g = 1 ∞∫ dkF(k ) ∫ dk 'G(k ')eik 'x' 1 ∞

∫ eix(k −k ')dx2π −∞ −∞ 2π−∞1442443

δ(k−k ')

or, ∞

f ⊗ g = 1 ∞∫ dkF(k ) ∫ dk 'G(k ')eik 'x ' δ(k − k ')

2π −∞ −∞

Integration over the delta function selects out the k’=k value.

f ⊗ g = 1 ∞∫ dkF(k)G(k)eikx'

2π−∞

22.058 - lecture 4, Convolution and Fourier Convolution

Page 17: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Proof of the Convolution Theorem

f ⊗ g = 1 ∞∫ dkF(k)G(k)eikx'

2π−∞

This is written as an inverse Fourier transformation. A Fourier transform of both sides yields the desired result.

ℑ{ f ⊗ g}= F(k) ⋅ G(k)

22.058 - lecture 4, Convolution and Fourier Convolution

Page 18: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

22.058 - lecture 4, Convolution and Fourier Convolution

Fourier Convolution

Page 19: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Reciprocal Space

real space reciprocal space

22.058 - lecture 4, Convolution and Fourier Convolution

Page 20: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Filtering

We can change the information content in the image by manipulating the information in reciprocal space.

Weighting function in k-space.

22.058 - lecture 4, Convolution and Fourier Convolution

Page 21: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Filtering

We can also emphasis the high frequency components.

Weighting function in k-space.

22.058 - lecture 4, Convolution and Fourier Convolution

Page 22: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Modulation transfer function

i(x, y) = o( x, y) ⊗ PSF( x, y) + noise c c c c

I (kx , ky ) = O(kx , ky ) ⋅ MTF(kx , ky )+ℑ{noise}

E( x, y) =

E( x, y) =

∞ ∞

∫∫ ∫∫ −∞ −∞

∞ ∞

∫∫ ∫∫ −∞ −∞

I ( x, y)S{δ( x − x0 )δ(y − y0 )}dxdydx0dy0

I ( x, y)IRF(x, y | x0, y0 )dxdydx0dy0

22.058 - lecture 4, Convolution and Fourier Convolution

Page 23: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with lens ‡ Input bit mapped image

sharp = Import @"sharp . bmp"D;

Shallow @InputForm @sharp DD

Graphics@Raster@<< 4>>D, Rule@<< 2>>DD

s = sharp @@1 , 1 DD;

Dimensions @s D

8 480, 640<

ListDensityPlot @s , 8PlotRange ÆAll , Mesh ÆFalse <D

22.058 - lecture 4, Convolution and Fourier Convolution

Page 24: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with lens

crop = Take @s , 8220 , 347 <, 864 , 572 , 4 <D;

‡ look at artifact in vertical dimension

rot = Transpose @crop D;120

line = rot @@20 DD;

100 ListPlot @line , 8PlotRange ÆAll , PlotJoined ÆTrue <D

80 120

100

60

80

40 60

4020

20 40 60 80 100 120 0 0 20 40 60 80 100 120 Ö GraphicsÖ

22.058 - lecture 4, Convolution and Fourier Convolution

Page 25: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with lens

20 40 60 80 100 120

40

60

80

100

120 ListPlot @RotateLeft @Abs @ftline D, 64 D, 8PlotJoined Æ

ü Fourier transform of vertical line to show modulation

2.5

5

7.5

10

12.5

15

20 40 60 80 100 120

ftline = Fourier @line D; Ö GraphicsÖ ListPlot @RotateLeft @Abs @ftline D, 64 D, 8PlotRange ÆAll , PlotJoined ÆTrue <D

200

400

600

800

1000

20 40 60 80 100 120

Ö GraphicsÖ 22.058 - lecture 4, Convolution and Fourier Convolution

Page 26: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with lens

2D FT

ftcrop = Fourier @crop D;

120120

100100

8080

6060

4040

2020

00

0 20 40 60 80 100 1200 20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 27: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with lens

Projections

120

100

80

20 40 60 80 100 120

200

400

600

800

1000

60

40

20

00 20 40 60 80 100 120

200

400

600

800

1000

20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 28: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with lens

Projections xprojection = Fourier @RotateLeft @rotft @@64 DD, 64 DD;

120

100

80

6050

100

150

200

250

300

20 40 60 80 100 12040

200

20150

0100

0 20 40 60 80 100 120

50

20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 29: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with pinhole

22.058 - lecture 4, Convolution and Fourier Convolution

Page 30: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

120 120

100 100

80 80

60 60

40 40

20 20

0 00 20 40 60 80 100 120 0 20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 31: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

2D FT

120120

100100

8080

6060

4040

2020

00

0 20 40 60 80 100 1200 20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 32: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Optics with pinhole

Projections

120

100

80

20 40 60 80 100 120

200

400

600

800

1000

1200

60

40

20

00 20 40 60 80 100 120

200

400

600

800

1000

1200

1400

20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 33: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Projections

50

100

150

200

250

300

20 40 60 80 100 120

200

150

100

50

20 40 60 80 100 120

100

150

200

250

20 40 60 80 100 120

100

150

200

20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 34: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Deconvolution to determine MTF of Pinhole

200

400

600

800

1000

1200

MTF= Abs @pinhole Dê Abs @image D;

ListPlot @MTF, 8PlotRange ÆAll , PlotJoined ÆTrue <

20 40 60 80 100 120

2

4

6

8

10

200

400

600

800

1000

20 40 60 80 100 120

Ö GraphicsÖ

20 40 60 80 100 120

22.058 - lecture 4, Convolution and Fourier Convolution

Page 35: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

FT to determine PSF of Pinhole MTF= Abs @pinhole Dê Abs @image D;

ListPlot @MTF, 8PlotRange ÆAll , PlotJoined ÆTrue <D

2

4

6

8

10

20 40 60 80 100 120

Ö GraphicsÖ PSF = Fourier @RotateLeft @MTF, 64 DD;

ListPlot @RotateLeft @Abs @PSF D, 64 D, 8PlotRange ÆAll , PlotJoined ÆTrue <D

7

6

5

4

3

2

1

20 40 60 80 100 120

22.058 - lecture 4, ConvolutÖ GraphicsÖ

Page 36: Convolution Fourier Convolution - MIT OpenCourseWare · Convolution Fourier Convolution Outline • Review linear imaging model • Instrument response function vs Point spread function

Filtered FT to determine PSF of PinholeMTF= Abs @pinhole Dê Abs @image D;

ListPlot @MTF, 8PlotRange ÆAll , PlotJoined ÆTrue <D

0.25

0.5

0.75

1

1.25

1.5

2

4

6

8

10

20 40 60 80 100 120 20 40 60 80 100 120

Filter = Table @Exp @- Abs @x - 64 Dê 15 D, 8x , 0 , 128 <D êê N;

ListPlot @Filter , 8PlotRange ÆAll , PlotJoined ÆTrue <D

1

0.8

0.6

0.4

0.2

20 40 60 80 100 120

Ö GraphicsÖ