sampling theory - cornell university

38
© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7 Sampling Theory CS5625 Lecture 7

Upload: others

Post on 18-Dec-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Sampling Theory

CS5625 Lecture 7

Page 2: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Sampling example (reminder)

• When we sample a high-frequency signal we don’t get what we expect– result looks like a lower frequency– not possible to distinguish between this and a low-frequency

signal

Page 3: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Sneak preview

• Sampling creates copies of the signal at higher frequencies

• Aliasing is these frequencies leaking into the reconstructed signal

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

Page 4: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Checkpoint

• Want to formalize sampling and reconstruction– define impulses– then we can talk about S&R with only one datatype

• Define Fourier transform• Destination: explaining how aliases leak into result

Page 5: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Mathematical model

• We have said sampling is storing the values on a grid• For analysis it’s useful to think of the sampled

representation in the same space as the original– I’ll do this using impulse functions at the sample points

Page 6: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Impulse function

• A function that is confined to a very small interval– but still has unit integral– really, the limit of a sequence of ever taller and narrower

functions– also called Dirac delta function

• Key property: multiplying by an impulse selects the value at a point– Defn via integral

• Impulse is the identity for convolution– “impulse response” of a filter

Page 7: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Sampling & recon. reinterpreted

• Start with a continuous signal• Convolve it with the sampling filter• Multiply it by an impulse grid• Convolve it with the reconstruction filter

Page 8: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

[F v

Page 9: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Checkpoint

• Formalized sampling and reconstruction– used impulses with multiplication and convolution– can talk about S&R with only one datatype

• Define Fourier transform• Destination: explaining how aliases leak into result

Page 10: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Fourier series

• Probably familiar idea of adding up sines and cosines to approximate a periodic function

Page 11: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Fourier series

Page 12: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Fourier transform

• Like Fourier series but for aperiodic functions– Fourier series: only multiples of base frequency

• Fourier transform: let period go to infinity– eventually all frequencies are needed– result: countable sum turns into integral

Page 13: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

The Fourier transform

• Any function on the real line can be represented as an infinite sum of sine waves

[F v

Page 14: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

The Fourier transform

Page 15: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

The Fourier transform

• The coefficients of those sine waves form a continuous function of frequency

• That function, which has the same datatype as the first one, is the Fourier transform.

• Phase encoded in complex number

Page 16: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Fourier transform properties

• F.T. is its own inverse (just about)• Frequency space is a dual representation

– amplitude known as “spectrum”

[FvD

FH fi

g.14

.15

/ Wol

berg

]

Page 17: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Fourier pairs

• sinusoid — impulse pair• box — sinc• tent — sinc2

• bspline — sinc4

• gaussian — gaussian (inv. width)

• imp. grid — imp. grid (1/d spacing)

[FvD

FH fi

g.14

.25

/ Wol

berg

]

Page 18: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

More Fourier facts

• F.T. preserves energy– That is, the squared integral

• DC component (average value)– It shows up at F(0)

Page 19: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

More Fourier facts

• Dilation (stretching/squashing)– Results in inverse dilation in F.T.

Page 20: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Convolution and multiplication

• They are dual to one another under F.T.

• Lowpass filters– Most of our “blurring” filters have most of their F.T. at low

frequencies– Therefore they attenuate higher frequencies

Page 21: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Checkpoint

• Formalized sampling and reconstruction– used impulses with multiplication and convolution

• Can talk about S&R with only one datatype• Defined Fourier transform

– alternate representation for functions– turns convolution, which seems hard, into multiplication,

which is easy

• Destination: explaining how aliases leak into result

Page 22: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

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

Page 23: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Aliasing in sampling/reconstruction

Page 24: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Aliasing in sampling

• If sampling filter is not adequate, spectra will overlap• No way to fix once it’s happened

– can only use drastic reconstruction filter to eliminate

• Nyquist criterion

Page 25: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Preventing aliasing in sampling

• Use high enough sample frequency– works when signal is band limited– sample rate 2 * (highest freq.) is enough to capture all details

• Filter signal to remove high frequencies– make the signal band limited– remove frequencies above 0.5 * (sample freq.) (Nyquist)

Page 26: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Effect of sample rate on aliasing

Page 27: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Smoothing (lowpass filtering)

Page 28: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Effect of smoothing on aliasing

Page 29: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Aliasing in reconstruction

• If reconstruction filter is inadequate, will catch alias spectra

• Result: high frequency alias components• Can happen even if sampling is ideal

Page 30: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Reconstruction filters

Page 31: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Sampling filters

• “Ideal” is box filter in frequency– which is sinc function in space

• Finite support is desirable– compromises are necessary

• Filter design: passband, stopband, and in between

[Gla

ssne

r fig

.5-2

7]

Page 32: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Useful sampling filters

• Sampling theory gives criteria for choosing• Box filter

– sampling: unweighted area average– reconstruction: e.g. LCD

• Gaussian filter– sampling: gaussian-weighted area average– reconstruction: e.g. CRT

• Piecewise cubic– good small-support reconstruction filter– popular choice for high-quality resampling

Page 33: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Resampling filters

• Resampling, logically, is two steps– first: reconstruct continuous signal– second: sample signal at the new sample rate

• Each step requires filtering– reconstruction filter– sampling filter

• This amounts to two successive convolutions– so regroup into one operation:

– single filter both reconstructs and antialiases

Page 34: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Resampling in frequency space

Page 35: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Sizing reconstruction filters

• Has to perform as a reconstruction filter– has to be at least big enough relative to input grid

• Has to perform as a sampling filter– has to be at least big enough relative to output grid

• Result: filter size is max of two grid spacings– upsampling (enlargement): determined by input– downsampling (reduction): determined by output– for intuition think of extreme case (10x larger or smaller)

Page 36: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

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

Page 37: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Supersampling

• When we can’t have a bandlimited signal we can improve matters by taking several samples per pixel– think of this as an estimate of the convolution integral

• Regular sampling is a simple quadrature rule:

• Irregular sampling can be seen as a Monte Carlo estimate:

I[i, j] =X

k

I(xk, yk) ⇡Z

I(x, y)p(x, y)dxdy

I[i, j] =X

k

I(xk, yk)Ak ⇡Z

I(x, y)dA

Page 38: Sampling Theory - Cornell University

© 2016 Steve Marschner • Cornell CS5625 Spring 2016 • Lecture 7

Regular supersampling in FT

• Really, we are first sampling at a higher rate, then convolving with the sampling filter– regular supersampling pushes the alias spectra farther away

from the main spectrum– the signal we are sampling still contains regular spikes, though

• Irregular sampling patterns have a different kind of FT440 J. Comput. Sci. & Technol., May 2015, Vol.30, No.3

(c)

0 45

Pow

erA

nis

otr

opy

90 135 180

0 45 90 135 180

2.0

1.5

1.0

0.5

0

10

5

0

-5

-10

(a)(b)

Fig. 1. Example of Poisson-disk sampling and its spectral analysis. (a) A sampled point set. (b) Power spectrum from this point set.(c) Radial means and normal anisotropy.

to noise with a flat spectrum, which contains an equal

amount of energy in all frequency bands. It is usually

used in random number generators[7]. Blue noise refers

to point distributions with weak low-frequency energy

rather than strong high-frequency energy. Pink noise

is the complement of blue noise and its spectral en-

ergy is concentrated in the low-frequency bands. Pink

noise occurs very frequently in nature and thus is used

for physical simulation and biological distributions[8-9].

Green noise is an uncommon term that can refer to the

mid-frequencies of white noise. It characterizes the dis-

tributions of a variety of natural phenomena and has

been used for digital halftoning[10].

There are also many other colors used for noise, with

or without precise definitions. In this paper, we focus

only on techniques that generate blue-noise sampling

patterns.

3 Blue-Noise Sampling

There are various ways to characterize existing blue-

noise sampling techniques. For example, the sampling

algorithms can be classified by the type of sampling

domain (2D, 3D, or surfaces), the metric used in the

domain (geodesic or Euclidean), the shape of the sam-

pling primitives (point, line, ball, etc.), the properties of

the sampling results (isotropic or anisotropic), the style

of the algorithm (dart throwing, relaxation, or tiling),

and so on.

3.1 Sampling Domain

Here, we briefly describe the common input do-

mains.

Euclidean Domain. Most previous blue-noise sam-pling algorithms were first developed to handle the 2Dor 3D Euclidean space. The traditional domain is theunit torus (i.e., the unit square and cube in 2D and 3D,respectively, with periodic boundary conditions)[11], inwhich the distance between two points is measured us-ing the Euclidean metric. Some work also addressesmore complicated domains, such as non-convex poly-gons with holes[12-13].

High Dimensions. Since high-dimensional point dis-tributions have special applications, some approachesare able to generalize blue-noise sampling to highdimensions[13-16]. However, many high-dimensionalsampling methods do not scale well with high dimen-sions because they typically suffer from the curse-of-dimensionality, which means that the effectivenessdeteriorates very rapidly as the dimensions increase.Ideas to overcome this problem have been suggestedby Ebeida et al.[17]

3D Surface. Blue-noise sampling has also been ex-tended to mesh surfaces. In this case, the input is usua-lly a two-manifold triangular mesh surface, which con-sists of a set of triangles. The sampled points shouldbe located exactly on the surface.

3.2 Sampling Algorithm

Blue-noise sampling methods can be roughly clas-sified into three types according to the techniquesthey use: 1) Poisson-disk sampling and its variations;2) relaxation-based sampling; and 3) patch/tile-basedsampling. In this subsection, we give an overview ofthese methods and discuss several classic algorithms indetail. Each type of algorithm is further classified bythe sampling domain. We emphasize methods that use

.

Dong-M

ing Yan et al. J Comp. Sci. Tech. 2015