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 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 )}dxdydx0 dy0 −∞ −∞ ∞ ∞ E( x, y) = ∫∫ ∫∫ I(x, y)IRF(x, y | x0 , y0 )dxdydx0 dy0 −∞ −∞ and so we need to know the IRF at all points. 22.058 - lecture 4, Convolution and Fourier Convolution 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 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 )dx0 dy0 −∞ or, Image( x, y) = Object ( x, y ) ⊗ PSF( x, y ) + noise 22.058 - lecture 4, Convolution and Fourier Convolution 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 Convolution Integrals Consider the following two functions: #1. Fold h(x’) about the line x’=0 #2. Displace h(x’) by x 22.058 - lecture 4, Convolution and Fourier Convolution x Convolution Integrals 22.058 - lecture 4, Convolution and Fourier Convolution Convolution Integrals Consider the following two functions: 22.058 - lecture 4, Convolution and Fourier Convolution Convolution Integrals 22.058 - lecture 4, Convolution and Fourier Convolution 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 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 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 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 15 15 10 10 5 5 1 2 3 -3 22.058 - lecture 4, Convolution and Fourier Convolution -2 -1 ? 1 2 3 Proof of the Convolution Theorem f ⊗g= ∞ ∫ f (x)g(x'−x)dx −∞ The inverse FT of f(x) is, 1 ∞ f (x) = ∫ F(k )eikx dk 2 π −∞ and the FT of the shifted g(x), that is g(x’-x) 1 ∞ g(x'−x) = ∫ G(k' )eik'(x'−x )dk' 2π −∞ 22.058 - lecture 4, Convolution and Fourier Convolution Proof of the Convolution Theorem So we can rewrite the convolution integral, f ⊗g= ∞ ∫ f (x)g(x'−x)dx −∞ as, f ⊗g= 1 ∞ ∞ ∞ 4π 2 −∞ −∞ −∞ ∫ dx ∫ F(k)eikx dk ∫ G(k' )eik'( x'− x )dk' change the order of integration and extract a delta function, ∞ ∞ 1 ∞ ik'x' 1 f ⊗g= ∫ dkF(k ) ∫ dk'G(k')e ∫ eix(k −k')dx 2π −∞ 2π −∞ −∞ 1442443 δ (k−k') 22.058 - lecture 4, Convolution and Fourier Convolution Proof of the Convolution Theorem ∞ ∞ 1 1 ∞ f ⊗g= ∫ dkF(k ) ∫ dk'G(k')eik'x' ∫ eix(k −k')dx 2π −∞ 2π −∞ −∞ 1442443 δ (k−k') or, ∞ 1 ∞ f ⊗g= ∫ dkF(k ) ∫ dk'G(k')eik'x'δ (k − k') 2π −∞ −∞ Integration over the delta function selects out the k’=k value. 1 ∞ f ⊗g= ∫ dkF(k)G(k)eikx' 2π −∞ 22.058 - lecture 4, Convolution and Fourier Convolution Proof of the Convolution Theorem 1 ∞ f ⊗g= ∫ 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 Fourier Convolution 22.058 - lecture 4, Convolution and Fourier Convolution Reciprocal Space real space 22.058 - lecture 4, Convolution and Fourier Convolution reciprocal space 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 Filtering We can also emphasis the high frequency components. Weighting function in k-space. 22.058 - lecture 4, Convolution and Fourier Convolution Modulation transfer function i(x, y) = o( x, y) ⊗ PSF( x, y) + noise c c c c I (k x , k y ) = O(k x , k y ) ⋅ MTF(kx , k y )+ ℑ{noise} ∞ ∞ E( x, y) = ∫∫ ∫∫ I ( x, y)S{δ ( x − x0 )δ (y − y0 )}dxdydx0 dy0 −∞ −∞ ∞ ∞ E( x, y) = ∫∫ ∫∫ I ( x, y)IRF(x, y | x0 , y0 )dxdydx0 dy0 −∞ −∞ 22.058 - lecture 4, Convolution and Fourier Convolution 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 22.058 - lecture 4, Convolution and Fourier Convolution <D Optics with lens crop = Take @s , 8220 , 347 <, 864 , 572 , 4 <D; ‡ look at artifact in vertical dimension rot 120 line 100 = Transpose @crop D; = rot @@20 DD; ListPlot @line , 8PlotRange ÆAll , PlotJoined 120 80 100 60 80 40 60 40 20 20 0 0 20 40 60 80 100 120 Ö Graphics Ö 22.058 - lecture 4, Convolution and Fourier Convolution 40 60 80 100 120 ÆTrue <D Optics with lens 120 ListPlot 100 15 80 12.5 @RotateLeft @Abs @ftline D, 64 D, 8PlotJoined 10 60 7.5 40 5 20 40 60 80 100 2.5 120 ü Fourier transform of vertical line to show modulation ftline ListPlot = Fourier @RotateLeft @line D; @Abs @ftline D, 64 D, 800 600 400 200 Ö Graphics Ö 40 60 80 100 40 60 Ö Graphics Ö 8PlotRange ÆAll , PlotJoined 1000 20 20 120 22.058 - lecture 4, Convolution and Fourier Convolution 80 100 120 ÆTrue <D Æ Optics with lens 2D FT ftcrop 120 @crop D; 120 100 100 80 80 60 60 40 40 20 0 0 = Fourier 20 20 40 60 80 100 120 22.058 - lecture 4, Convolution and Fourier Convolution 0 0 20 40 60 80 100 120 Optics with lens Projections 1000 800 600 120 400 100 200 80 20 40 60 80 100 120 20 40 60 80 100 120 60 40 1000 800 20 600 0 0 20 40 60 80 100 120 400 200 22.058 - lecture 4, Convolution and Fourier Convolution Optics with lens Projections xprojection = Fourier @RotateLeft @rotft @@64 DD, 64 DD; 300 120 250 200 100 150 80 100 50 60 20 40 60 80 100 120 200 20 0 0 40 150 20 40 60 80 100 120 100 50 20 22.058 - lecture 4, Convolution and Fourier Convolution 40 60 80 100 120 Optics with pinhole 22.058 - lecture 4, Convolution and Fourier Convolution 120 120 100 100 80 80 60 60 40 40 20 20 0 0 20 40 60 80 100 120 22.058 - lecture 4, Convolution and Fourier Convolution 0 0 20 40 60 80 100 120 2D FT 120 120 100 100 80 80 60 60 40 40 20 0 0 20 20 40 60 80 100 120 22.058 - lecture 4, Convolution and Fourier Convolution 0 0 20 40 60 80 100 120 Optics with pinhole Projections 1200 1000 800 120 600 100 400 200 80 20 40 60 80 100 120 20 40 60 80 100 120 60 1400 40 1200 1000 20 800 0 0 600 20 40 60 80 100 120 400 200 22.058 - lecture 4, Convolution and Fourier Convolution Projections 300 250 250 200 200 150 150 100 100 50 20 20 40 60 80 100 40 60 80 100 120 120 200 200 150 150 100 100 50 20 20 40 60 80 100 120 22.058 - lecture 4, Convolution and Fourier Convolution 40 60 80 100 120 Deconvolution to determine MTF of Pinhole 1200 1000 800 MTF = Abs @pinhole 600 ListPlot 400 Dê Abs @image D; @MTF, 8PlotRange ÆAll , PlotJoined 10 200 8 20 40 60 80 100 120 6 1000 4 800 2 600 20 400 Ö Graphics Ö 200 20 40 60 80 100 120 22.058 - lecture 4, Convolution and Fourier Convolution 40 60 80 100 120 ÆTrue < FT to determine PSF of Pinhole MTF = Abs @pinhole ListPlot Dê Abs @image D; @MTF, 8PlotRange ÆAll , PlotJoined ÆTrue <D 10 8 6 4 2 20 Ö Graphics Ö 40 60 80 PSF = Fourier ListPlot 100 120 @RotateLeft @RotateLeft @MTF, 64 DD; @Abs @PSF D, 64 D, 8PlotRange 7 6 5 4 3 2 1 20 22.058 - lecture 4, Convolut Ö Graphics Ö 40 60 80 100 120 ÆAll , PlotJoined ÆTrue <D Filtered FT to determine PSF of Pinhole MTF = Abs @pinhole ListPlot Dê Abs @image D; @MTF, 8PlotRange ÆAll , PlotJoined ÆTrue <D 10 1.5 8 1.25 1 6 0.75 4 0.5 2 0.25 20 Filter ListPlot 40 60 80 100 20 120 = Table @Exp @- Abs @x - 64 Dê 15 D, 8x , 0 , 128 <D êê N; @Filter , 8PlotRange ÆAll , PlotJoined 1 0.8 0.6 0.4 0.2 20 Ö Graphics Ö 40 60 80 100 120 ÆTrue <D 40 60 80 100 120