Sampling and Reconstruction Introduction Signal Processing
Total Page:16
File Type:pdf, Size:1020Kb
Introduction • A theoretical basis for antialiasing – provides explanations for how aliasing appears – answers questions about what to do in practice Sampling and Reconstruction • Imported from the signal processing community CS417 Lecture 5 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 1 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 2 Signal processing Continuous and discrete • Discrete representations of continuous functions • Raster image = discrete representation of continuous – note abuse of “continuous” 2D function • Relevant math worked out by Nyquist in the 1920s • Sampling and reconstruction are just conversions back – early practical use: digital audio recording (1960s) and forth between functions and this discrete • Applies to multidimensional “signals” like images representation – this lecture is in 1D but it’s understood to apply in 2D Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 3 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 4 Continuous to discrete Sampling example • Sampling is simple • When we sample a high-frequency signal we don’t get – given a function and a sampling grid what we expect – write down function values at all sample points – result looks like a lower frequency • Aliasing – not possible to distinguish between this and a low-frequency signal – saw last time that area averaging is a good idea – why? Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 5 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 6 1 Discrete to continuous Sneak preview • From samples must define continuous function • Sampling creates copies of the signal at higher • Practical examples frequencies – LCD: piecewise constant • Aliasing is these frequencies leaking into the – CRT: sum of blurred gaussians reconstructed signal • amounts to summing up translated functions – frequency fs – x shows up as frequency x • The solution is filtering – during sampling, filter to keep the high frequencies out so they don’t create aliases at the lower frequencies – during reconstruction, again filter high frequencies to avoid including high-frequency aliases in the output. Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 7 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 8 Mathematical model Impulse function • We have said sampling is storing the values on a grid • A function that is confined to a very small interval • For analysis it’s useful to think of the sampled – but still has unit integral representation in the same space as the original – really, the limit of a sequence of ever taller and narrower – I’ll do this using impulse functions at the sample points functions – also called Dirac delta function • Key property: multiplying by an impulse selects the value at a point Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 9 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 10 Convolution Sampling & recon. reinterpreted • Another building block for analysis • Start with a continuous signal • Defines an operation * on two functions • Convolve it with the sampling filter – locally average one function using the other as the weight • Multiply it by an impulse grid • Convolve it with the reconstruction filter – is commutative and associative • Impulse is the identity for convolution – “impulse response” of a filter Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 11 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 12 2 Checkpoint • Want to formalize sampling and reconstruction • Defined impulses and convolution • Using those, can talk about S&R with only one datatype • Destination: explaining how aliases leak into result ] Wolberg fig.14.14b / FvDFH [ Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 13 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 14 The Fourier transform The Fourier transform • Any function on the real line can be represented as an • The coefficients of those sine waves form a continuous infinite sum of sine waves function of frequency • That function, which has the same datatype as the first one, is the Fourier transform. ] Wolberg • Phase encoded in complex number fig.14.14b / FvDFH [ Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 15 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 16 Fourier transform properties Fourier pairs • F.T. is its own inverse • sinusoid — impulse pair • Frequency space is a dual representation • box — sinc – amplitude known as “spectrum” • gaussian — gaussian (inv. width) • impulse grid — impulse grid (1/d spacing) ] ] Wolberg Wolberg fig.14.15 / fig.14.25 / FvDFH FvDFH [ [ Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 17 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 18 3 Convolution and multiplication Checkpoint • They are dual to one another under F.T. • Formalized sampling and reconstruction – used multiplication and convolution • Introduced Fourier transform – alternate representation for functions – turns convolution, which seems hard, into multiplication, • Lowpass filters which is easy Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 19 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 20 Sampling and reconstruction in F.T. • Look at our sampling/reconstruction formulation in Fourier domain – Convolve with filter = remove high frequencies – Multiply by impulse grid = convolve with impulse grid • that is, make a bunch of copies – Convolve with filter = remove extra copies ] – Left with approximation of original • but filtered a couple of times Wolberg fig.14.29 / FvDFH [ Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 21 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 22 Aliasing in sampling Aliasing in reconstruction • If sampling filter is not adequate, spectra will overlap • If reconstruction filter is inadequate, will catch alias • No way to fix once it’s happened spectra – can only use drastic reconstruction filter to eliminate • Result: high frequency alias components • Nyquist criterion • Can happen even if sampling is ideal Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 23 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 24 4 Sampling filters Useful sampling filters • “Ideal” is box filter in frequency • Sampling theory gives criteria for choosing – which is sinc function in space • Box filter • Finite support is desirable – sampling: unweighted area average – compromises are necessary – reconstruction: e.g. LCD • Filter design: passband, stopband, and in between • Gaussian filter – sampling: gaussian-weighted area average – reconstruction: e.g. CRT • Piecewise cubic fig.5-27] – good small-support reconstruction filter Glassner [ – popular choice for high-quality resampling (next lecture) Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 25 Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 26 Summary • Want to explain aliasing and answer questions about how to avoid it • Formalized sampling and reconstruction using impulse grids and convolution • Fourier transform gives insight into what happens when we sample • Nyquist criterion tells us what kind of filters to use Cornell CS417 Spring 2003 • Lecture 5 © 2003 Steve Marschner • 27 5.