99
Lecture 13 • Cornell CS4620 Fall 2013 Sampling and reconstruction CS 4620 Lecture 13 1

Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Sampling and reconstruction

CS 4620 Lecture 13

1

Page 2: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Sampled representations

• How to store and compute with continuous functions?

• Common scheme for representation: sampleswrite down the function’s values at many points

[FvD

FH fi

g.14

.14b

/ W

olbe

rg]

2

Page 3: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Reconstruction

• Making samples back into a continuous functionfor output (need realizable method)

for analysis or processing (need mathematical method)

amounts to “guessing” what the function did in between

[FvD

FH fi

g.14

.14b

/ W

olbe

rg]

3

Page 4: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Filtering

• Processing done on a functioncan be executed in continuous form (e.g. analog circuit)

but can also be executed using sampled representation

• Simple example: smoothing by averaging

4

Page 5: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Roots of sampling

• Nyquist 1928; Shannon 1949famous results in information theory

• 1940s: !rst practical uses in telecommunications

• 1960s: !rst digital audio systems

• 1970s: commercialization of digital audio

• 1982: introduction of the Compact Discthe !rst high-pro!le consumer application

• This is why all the terminology has a communications or audio “"avor”

early applications are 1D; for us 2D (images) is important

5

Page 6: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Sampling in digital audio

• Recording: sound to analog to samples to disc

• Playback: disc to samples to analog to sound againhow can we be sure we are !lling in the gaps correctly?

6

Page 7: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Undersampling

• What if we “missed” things between the samples?

• Simple example: undersampling a sine waveunsurprising 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

7

Page 8: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Undersampling

• What if we “missed” things between the samples?

• Simple example: undersampling a sine waveunsurprising 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

7

Page 9: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Undersampling

• What if we “missed” things between the samples?

• Simple example: undersampling a sine waveunsurprising 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

7

Page 10: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Undersampling

• What if we “missed” things between the samples?

• Simple example: undersampling a sine waveunsurprising 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

7

Page 11: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Undersampling

• What if we “missed” things between the samples?

• Simple example: undersampling a sine waveunsurprising 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

7

Page 12: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Undersampling

• What if we “missed” things between the samples?

• Simple example: undersampling a sine waveunsurprising 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

7

Page 13: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

© 2005 Steve Marschner • Cornell CS465 Fall 2005 • Lecture 6

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 14: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Preventing aliasing

• Introduce lowpass !lters:remove high frequencies leaving only safe, low frequencies

choose lowest frequency in reconstruction (disambiguate)

9

Page 15: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Preventing aliasing

• Introduce lowpass !lters:remove high frequencies leaving only safe, low frequencies

choose lowest frequency in reconstruction (disambiguate)

9

Page 16: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Linear !ltering: a key idea

• Transformations on signals; e.g.:bass/treble controls on stereo

blurring/sharpening operations in image editing

smoothing/noise reduction in tracking

• Key propertieslinearity: !lter(f + g) = !lter(f) + !lter(g)

shift invariance: behavior invariant to shifting the input• delaying an audio signal• sliding an image around

• Can be modeled mathematically by convolution

10

Page 17: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution warm-up

• basic idea: de!ne a new function by averaging over a sliding window

• a simple example to start off: smoothing

11

Page 18: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution warm-up

• basic idea: de!ne a new function by averaging over a sliding window

• a simple example to start off: smoothing

11

Page 19: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution warm-up

• basic idea: de!ne a new function by averaging over a sliding window

• a simple example to start off: smoothing

11

Page 20: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution warm-up

• basic idea: de!ne a new function by averaging over a sliding window

• a simple example to start off: smoothing

11

Page 21: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution warm-up

• basic idea: de!ne a new function by averaging over a sliding window

• a simple example to start off: smoothing

11

Page 22: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution warm-up

• Same moving average operation, expressed mathematically:

12

Page 23: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Discrete convolution

• Simple averaging:

every sample gets the same weight

• Convolution: same idea but with weighted average

each sample gets its own weight (normally zero far away)

• This is all convolution is: it is a moving weighted average

13

Page 24: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Filters

• Sequence of weights a[j] is called a filter

• Filter is nonzero over its region of supportusually centered on zero: support radius r

• Filter is normalized so that it sums to 1.0this makes for a weighted average, not just any

old weighted sum

• Most !lters are symmetric about 0since for images we usually want to treat

left and right the same

a box !lter

14

Page 25: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution and !ltering

• Can express sliding average as convolution with a box filter

• abox = […, 0, 1, 1, 1, 1, 1, 0, …]

15

Page 26: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Example: box and step

16

Page 27: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Example: box and step

16

Page 28: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Example: box and step

16

Page 29: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Example: box and step

16

Page 30: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Example: box and step

16

Page 31: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution and !ltering

• Convolution applies with any sequence of weights

• Example: bell curve (gaussian-like) […, 1, 4, 6, 4, 1, …]/16

17

Page 32: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Convolution and !ltering

• Convolution applies with any sequence of weights

• Example: bell curve (gaussian-like) […, 1, 4, 6, 4, 1, …]/16

17

Page 33: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Discrete convolution

• Notation:

• Convolution is a multiplication-like operationcommutative

associative

distributes over addition

scalars factor out

identity: unit impulse e = […, 0, 0, 1, 0, 0, …]

• Conceptually no distinction between !lter and signal

18

Page 34: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Discrete !ltering in 2D

• Same equation, one more index

now the !lter is a rectangle you slide around over a grid of numbers

• Commonly applied to imagesblurring (using box, using gaussian, …)

sharpening (impulse minus blur)

• Usefulness of associativityoften apply several !lters one after another: (((a * b1) * b2) * b3)

this is equivalent to applying one !lter: a * (b1 * b2 * b3)

19

Page 35: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

original    |    box blur sharpened    |    gaussian blur[Philip Greenspun]

20

Page 36: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

original    |    box blur sharpened    |    gaussian blur[Philip Greenspun]

20

Page 37: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous convolution: warm-up

• Can apply sliding-window average to a continuous function just as well

output is continuous

integration replaces summation

21

Page 38: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous convolution: warm-up

• Can apply sliding-window average to a continuous function just as well

output is continuous

integration replaces summation

21

Page 39: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous convolution: warm-up

• Can apply sliding-window average to a continuous function just as well

output is continuous

integration replaces summation

21

Page 40: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous convolution: warm-up

• Can apply sliding-window average to a continuous function just as well

output is continuous

integration replaces summation

21

Page 41: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous convolution: warm-up

• Can apply sliding-window average to a continuous function just as well

output is continuous

integration replaces summation

21

Page 42: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous convolution

• Sliding average expressed mathematically:

note difference in normalization (only for box)

• Convolution just adds weights

weighting is now by a function

weighted integral is like weighted average

again bounds are set by support of f(x)

22

Page 43: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

One more convolution

• Continuous–discrete convolution

used for reconstruction and resampling

23

Page 44: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous-discrete convolution

24

Page 45: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous-discrete convolution

24

Page 46: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous-discrete convolution

24

Page 47: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous-discrete convolution

24

Page 48: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Continuous-discrete convolution

24

Page 49: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling

• Changing the sample ratein images, this is enlarging and reducing

• Creating more samples:increasing the sample rate

“upsampling”

“enlarging”

• Ending up with fewer samples:decreasing the sample rate

“downsampling”

“reducing”

25

Page 50: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling

• Reconstruction creates a continuous functionforget its origins, go ahead and sample it

26

Page 51: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling

• Reconstruction creates a continuous functionforget its origins, go ahead and sample it

26

Page 52: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling

• Reconstruction creates a continuous functionforget its origins, go ahead and sample it

26

Page 53: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling

• Reconstruction creates a continuous functionforget its origins, go ahead and sample it

26

Page 54: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling

• Reconstruction creates a continuous functionforget its origins, go ahead and sample it

26

Page 55: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Cont.–disc. convolution in 2D

• same convolution—just two variables now

loop over nearby pixels, average using !lter weight

looks like discrete !lter,but offsets are not integersand !lter is continuous

remember placement of !lterrelative to grid is variable

27

Page 56: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Cont.–disc. convolution in 2D

28

Page 57: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

A gallery of !lters

• Box !lterSimple and cheap

• Tent !lterLinear interpolation

• Gaussian !lterVery smooth antialiasing !lter

• B-spline cubicVery smooth

• Catmull-rom cubicInterpolating

• Mitchell-Netravali cubicGood for image upsampling

29

Page 58: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Box !lter

30

Page 59: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Tent !lter

31

Page 60: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Gaussian !lter

32

Page 61: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

B-Spline cubic

33

fB(x) =16

�⌅⇤

⌅⇥

�3(1� |x|)3 + 3(1� |x|)2 + 3(1� |x|) + 1 �1 ⇥ x ⇥ 1,

(2� |x|)3 1 ⇥ |x| ⇥ 2,

0 otherwise.

Page 62: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Catmull-Rom cubic

34

fC(x) =12

�⌅⇤

⌅⇥

�3(1� |x|)3 + 4(1� |x|)2 + (1� |x|) �1 ⇥ x ⇥ 1,

(2� |x|)3 � (2� |x|)2 1 ⇥ |x| ⇥ 2,

0 otherwise.

Page 63: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Michell-Netravali cubic

35

fM (x) =13fB(x) +

23fC(x)

=118

�⌅⇤

⌅⇥

�21(1� |x|)3 + 27(1� |x|)2 + 9(1� |x|) + 1 �1 ⇥ x ⇥ 1,

7(2� |x|)3 � 6(2� |x|)2 1 ⇥ |x| ⇥ 2,

0 otherwise.

Page 64: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Effects of reconstruction !lters

• For some !lters, the reconstruction process winds up implementing a simple algorithm

• Box !lter (radius 0.5): nearest neighbor samplingbox always catches exactly one input point

it is the input point nearest the output point

so output[i, j] = input[round(x(i)), round(y(j))]x(i) computes the position of the output coordinate i on the input grid

• Tent !lter (radius 1): linear interpolationtent catches exactly 2 input points

weights are a and (1 – a)

result is straight-line interpolation from one point to the next

36

Page 65: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Properties of !lters

• Degree of continuity

• Impulse response

• Interpolating or no

• Ringing, or overshoot

interpolating filter used for reconstruction

37

Page 66: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Ringing, overshoot, ripples

• Overshootcaused by

negative !ltervalues

• Ripplesconstant in,

non-const. out

ripple free when:

38

Page 67: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Constructing 2D !lters

• Separable !lters (most common approach)

39

Page 68: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 69: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 70: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 71: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 72: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 73: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 74: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 75: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 76: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 77: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 78: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 79: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 80: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Yucky details

• What about near the edge?the !lter window falls off the edge of the image

need to extrapolate

methods:• clip !lter (black)• wrap around• copy edge• re"ect across edge• vary !lter near edge

40

[Phi

lip G

reen

spun

]

Page 81: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Reducing and enlarging

• Very common operationdevices have differing resolutions

applications have different memory/quality tradeoffs

• Also very commonly done poorly

• Simple approach: drop/replicate pixels

• Correct approach: use resampling

41

Page 82: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 83: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 84: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 85: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 86: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 87: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 88: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 89: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 90: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 91: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Resampling example

42

Page 92: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Reducing and enlarging

• Very common operationdevices have differing resolutions

applications have different memory/quality tradeoffs

• Also very commonly done poorly

• Simple approach: drop/replicate pixels

• Correct approach: use resampling

43

Page 93: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

1000 pixel width [Philip Greenspun]

44

Page 94: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

250 pixel width

by dropping pixels gaussian !lter

[Philip Greenspun]

45

Page 95: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

4000 pixel width

box reconstruction !lter bicubic reconstruction !lter

[Phi

lip G

reen

spun

]

46

Page 96: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Types of artifacts

• Garden varietywhat we saw in this natural image

!ne features become jagged or sparkle

• Moiré patterns

47

Page 97: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

600ppi scan of a color halftone image

[Hea

rn &

Bak

er c

over

]

48

Page 98: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

downsampling a high resolution scan

by dropping pixels gaussian !lter

[Hea

rn &

Bak

er c

over

]

49

Page 99: Sampling and reconstruction - Cornell University• Sampling creates copies of the signal at higher frequencies • Aliasing is these frequencies leaking into the reconstructed signal

Lecture 13 • Cornell CS4620 Fall 2013

Types of artifacts

• Garden varietywhat we saw in this natural image

!ne features become jagged or sparkle

• Moiré patternscaused by repetitive patterns in input

produce large-scale artifacts; highly visible

• These artifacts are aliasing just like in the audio example earlier

• How do I know what !lter is best at preventing aliasing?practical answer: experience

theoretical answer: there is another layer of cool math behind all this• based on Fourier transforms• provides much insight into aliasing, !ltering, sampling, and reconstruction

50