chapter 13 review of sampling - college of science | rit

12
Chapter 13 Review of Sampling 13.1 Digitization Digitization is the conversion of a continuous-tone and spatially continuous brightness distribution f [x, y] to an discrete array of integers f q [n, m] by two operations which will be discussed in turn: (A) SAMPLING — a function of continuous coordinates f [x, y] is evaluated on a discrete matrix of samples indexed by [n, m]. (B) QUANTIZATION — the continuously varying brightness f at each sample is converted to a one of set of integers f q by some nonlinear thresholding process. The digital image is a matrix of picture elements, or pixels if your ancestors are computers. Video descendents (and imaging science undergraduates) often speak of pels (often misspelled pelz ). Each matrix element is an integer which encodes the brightness at that pixel. The integer value is called the gray value or digital coun t of the pixel. Computers store integers as BInary digiTS, or bits (0,1) 2 bits can represent: 00 4 =0., 01 4 =1, 10 4 =2., 11 4 =3.;a total of 2 2 =4 numbers. (The symbol “ 4 ” denotes the binary analogue to the decimal point “.”, that is, the binary point divides the ordered bits with positive and negative powers of 2). m BITS can represent 2 m numbers = 8 BITS =1 BYTE = 256 decimal numbers, [0, 255] Note that digitized image contains a nite amount of information: the number of bits required to store the data. This will usually be less than the quantity of information in the original image. In other words, digitization creates errors. We will discuss digitizing and reconstruction error after describing the image display process. 269

Upload: others

Post on 09-Nov-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 13 Review of Sampling - College of Science | RIT

Chapter 13

Review of Sampling

13.1 Digitization

Digitization is the conversion of a continuous-tone and spatially continuous brightnessdistribution f [x, y] to an discrete array of integers fq[n,m] by two operations whichwill be discussed in turn:(A) SAMPLING — a function of continuous coordinates f [x, y] is evaluated on a

discrete matrix of samples indexed by [n,m].(B) QUANTIZATION — the continuously varying brightness f at each sample is

converted to a one of set of integers fq by some nonlinear thresholding process.The digital image is a matrix of picture elements, or pixels if your ancestors are

computers. Video descendents (and imaging science undergraduates) often speak ofpels (often misspelled pelz). Each matrix element is an integer which encodes thebrightness at that pixel. The integer value is called the gray value or digital count ofthe pixel.Computers store integers as BInary digiTS, or bits (0,1)

2 bits can represent: 004 = 0., 014 = 1, 104 = 2., 114 = 3.;a total of 22 = 4numbers.

(The symbol “4” denotes the binary analogue to the decimal point “.”, that is,the binary point divides the ordered bits with positive and negative powers of 2).

m BITS can represent 2m numbers =⇒ 8 BITS = 1 BYTE =⇒ 256 decimalnumbers, [0, 255]

Note that digitized image contains a finite amount of information: the numberof bits required to store the data. This will usually be less than the quantity ofinformation in the original image. In other words, digitization creates errors. We willdiscuss digitizing and reconstruction error after describing the image display process.

269

Page 2: Chapter 13 Review of Sampling - College of Science | RIT

270 CHAPTER 13 REVIEW OF SAMPLING

13.2 Sampling

This operation derives a discrete set of data points at (usually) uniform spacing. In itssimplest form, sampling is expressed mathematically as multiplication of the originalimage by a function that measures the image brightness at discrete locations:

fs [n ·∆x] = f [x] · s [x;n ·∆x]

where:

f [x] = brightness distribution of input image

s [x;n ·∆x] = sampling function

fs [n ·∆x] = sampled input image defined at coordinates n ·∆x

The ideal sampling function for functions of continuous variables is generated fromthe so-called “Dirac delta function” δ [x], which is defined by many authors, includingGaskill. For the (somewhat less rigorous) purpose here, we may consider the samplingfunction to be the sum of uniformly spaced “discrete” Dirac delta functions, whichGaskill calls the COMB and Bracewell calls it the SHAH :

s [x;n ·∆x] ≡

⎧⎨⎩ 1 if x = n ·∆x(n = 0,±1,±2, . . .)

0 otherwise

The COMB function defined by Gaskill (called the SHAH function by Bracewell).

13.2.1 Ideal Sampling

Multiplication of the input f [x] by a COMB function merely evaluates f [x] on theuniform grid of points located at n ·∆x, where n is an integer. Because it measuresthe value of the input at an infinitesmal point, this is a mathematical idealizationthat cannot be implemented in practice. Even so, the discussion of ideal samplingusefully introduces some essential concepts.Consider ideal sampling of a sinusoidal input function with spatial period X0 that

Page 3: Chapter 13 Review of Sampling - College of Science | RIT

13.2 SAMPLING 271

is ideally sampled at intervals separated by ∆x:

f [x] =1

2

∙1 + cos

∙2πx

X0+ φ

¸¸=⇒ fs [n ·∆x] =

1

2

∙1 + cos

∙2πx

X0+ φ

¸¸· COMB

h x

∆x

i

The amplitude of the function at the sample indexed by n is:

fs [n ·∆x] =1

2

µ1 + cos

∙2πx

X0+ φ)

¸¶· δ [x− n ·∆x]

= fs [n ·∆x] =1

2·µ1 + cos

∙2πn

µ∆x

X0

¶+ φ

¸¶The dimensionless parameter ∆x

X0is the ratio of the sampling interval to the spatial

period (wavelength) of the sinusoid and is a measurement of the fidelity of the sampledimage. Mathematical expressions for the sampled function fs obtained for severalvalues of ∆x

X0are:

Case I:∆x

X0=1

12, φ = 0 =⇒ fs [n] =

1

2·³1 + cos

hπn6

i´Case II:

∆x

X0=1

2, φ = 0 =⇒ fs [n] =

1

2· (1 + cos [πn]) = 1

2[1 + (−1)n]

Case III:∆x

X0=1

2, φ = −π

2=⇒ fs [n] =

1

2· (1 + sin [πn]) = 1

2

Case IV:∆x

X0=3

4, φ = 0 =⇒ fs [n] =

1

2·µ1 + cos

∙3πn

2

¸¶Case V:

∆x

X0=5

4, φ = 0 =⇒ fs [n] =

1

2·µ1 + cos

∙5πn

2

¸¶

Page 4: Chapter 13 Review of Sampling - College of Science | RIT

272 CHAPTER 13 REVIEW OF SAMPLING

Illustration of sampling of a biased sinusoid, showing aliasing if the signal oscillateswith a period smaller than 2 ·∆x.

The output evaluated for ∆xX0= 1

2depends on the phase of the sinusoid; if sampled

at the extrema, then the sampled signal has the same dynamic range as f [x] (i.e.,it is fully modulated), show no modulation, or any intermediate value. The interval∆x = X0

2defines the Nyquist sampling limit. If ∆x

X0> 1

2sample per period, then the

same set of samples could have been obt5ained from a sinusoid with a longer periodand a different sampling interval ∆x. For example, if ∆x

X0= 3

4, then the reconstructed

function appears as though obtained from a sinudoid with periodX 00 = 3X0 if sampled

with ∆xX00= 1

4. In other words, the data set of samples is ambiguous; the same samples

Page 5: Chapter 13 Review of Sampling - College of Science | RIT

13.3 ALIASING —WHITTAKER-SHANNONSAMPLINGTHEOREM273

could be obtained from more than one input, and thus we cannot distinguish amongthe possible inputs based only on knowledge of the samples.

13.3 Aliasing —Whittaker-Shannon Sampling The-orem

As just demonstrated, the sample values obtained from a sinusoid which has beensampled fewer than two times per period will be identical to those from a sinusoidwith a longer period. This ambiguity is called aliasingin sampling, but similar effects show up whenever periodic functions are multiplied

or added. In other disciplines, these go by different names such as beats, Moiré fringes,and heterodyning. To illustrate, consider the product of two sinusoidal functions withthe different periods X1and X2(and thus spatial frequencies ξ1 = 1

X1, ξ2 =

1X2).

cos [2πξ1x] · cos [2πξ2x] =1

2cos [2π(ξ1 + ξ2)x] +

1

2cos [2π(ξ1 − ξ2)x]

The second term oscillates slowly and is the analog of the aliased signal.Though the proof is beyond our mathematical scope at this time, we state that

a sinusoidal signal that has been sampled without aliasing can be perfectly recon-structed from its ideal samples. This will be demonstrated in the section on imagedisplays. Also without proof, we make the following claim:

Any function can be expressed as a unique sum of sinusoidal componentswith (generally) different amplitudes, frequencies, and phases.

If the sinusoidal representation of f [x] has a component with a maximum spatialfrequency ξmax, and if we sample f [x] so that this component is sampled without alias-ing, then all sinusoidal components of f [x] will be adequately sampled and f [x]canbe perfectly reconstructed from its samples. Such a function is band-limited andξmax is the cutoff frequency of f [x]. The corresponding minimum spatial period isXmin =

1ξmax

. Thus the sampling interval ∆x can be found from:

∆x

Xmin<1

2=⇒ ∆x <

Xmin

2=⇒ ∆x <

1

2ξmax

This is the Whittaker-Shannon sampling theorem. The limiting value of the sam-pling interval ∆x = 1

2ξmaxdefines the Nyquist sampling limit. Sampling more or less

frequently than the Nyquist limit is oversampling or undersampling, respectively.

∆x >1

2ξmax=⇒ undersampling

∆x <1

2ξmax=⇒ oversampling

Page 6: Chapter 13 Review of Sampling - College of Science | RIT

274 CHAPTER 13 REVIEW OF SAMPLING

The Whittaker-Shannon Sampling Theorem is valid for all types of sampled sig-nals. An increasingly familiar example is digital recording of audio signals (e.g., forcompact discs or digital audio tape). The sampling interval is determined by themaximum audible frequency of the human ear, which is generally accepted to beapproximately 20kHz. The sampling frequency of digital audio recorders is 44,000samplessecond which translates to a sampling interval of

144,000 s

= 22.7µs. At this samplingrate, sounds with periods greater than 2 · 22.7µs = 45.4µs (or frequencies less than(45.4µs)−1 = 22 kHz) can theoretically be reconstructed perfectly, assuming thatf [t] is sampled perfectly (i.e., at a point). Note that if the input signal frequency isgreater than the Nyquist frequency of 22 kHz, the signal will be aliased and will ap-pear as a lower-frequency signal in the audible range. Thus the reconstructed signalwill be wrong. This is prevented by ensuring that no signals with frequencies abovethe Nyquist limit is allowed to reach the sampler; higher frequencies are filtered outbefore sampling.

13.4 Realistic Sampling — Averaging by the Detec-tor

Signals cannot really be sampled at infinitesimal points by multiplication by a COMB;this would mean that the signal would be measued by a detector that has infinitesimalarea; such a measurement would have infinitesimal magnitude. In realistic sampling,the continuous input is measured at uniformly spaced samples by using a detectorwith finite spatial (or temporal) size. The measured signal is an average of the inputthe detector area, and the image structure is blurred by the averaging process:

Realistic sampling averages the signal over a finite area and blurs informationabout fine structure that existed in the original continuous image.

The discrete samples are obtained by averaging the input at the sample coordi-nates. This is mathematically equivalent to averaging the continuous input f [x] withthe detector weighting function h1 [x] and sampling the result by multiplication witha COMB function. Spatial averaging may be expressed as the integral of the productof the input function and the averaging (weighting) function h1 [x], and is called aconvolution. The averaging process is sometimes called prefiltering, or antialiasing:Z +∞

−∞f [x− x0] · h1 [x] dx ≡ (f [x] ∗ h1 [x]) |x=x0

The sampled signal is obtained by multiplying the averaged signal by the COMB:

Page 7: Chapter 13 Review of Sampling - College of Science | RIT

13.4 REALISTIC SAMPLING — AVERAGING BY THE DETECTOR275

fs [n ·∆x] = (f [x] ∗ h1 [x]) · COMBh x

∆x

iwhere:

f [x] = brightness distribution of input image

h1 [x] = antialiasing prefilter

fs [n ·∆x] = sampled input image defined at coordinates n ·∆x

realistic sampling is composed of two cascaded operations:

(1) averaging (convolution, prefiltering) over a detector function, and

(2) multiplication by an ideal sampling function COMB£

x∆x

¤

The nature of the antialiasing prefilter determines the effect of realistic sampling onthe output. This is typically characterized by measuring the effect on the modulationof a sinusoidal wave f [x] = 1

2(1 + cos [2πξ0x]). The modulation of a sinusoid is

defined as:

m =fmax − fmin

fmax + fminfor 0 ≤ m ≤ 1

Note that modulation is defined for nonnegative (i.e., biased) sinusoids ONLY. Theanalogous quantity for a nonnegative square wave is called contrast. For example,consider a sinusoid with unit modulation that is sampled by an array with elementsof width d spaced at intervals of width ∆x as shown:

Schematic of sampling of a biased nonnegative sinusoid with detectors of width dspaced at intervals of ∆x.

The signal is averaged over the detector area, e.g., the sampled value at n = 0 is:

Page 8: Chapter 13 Review of Sampling - College of Science | RIT

276 CHAPTER 13 REVIEW OF SAMPLING

fs [n = 0] =1

d

Z d2

−d2

f [x] dx

=

Z +∞

−∞f [x] ·

µ1

dRECT

hxd

i¶dx

where: RECThxd

i≡

⎧⎪⎪⎪⎨⎪⎪⎪⎩1 if |x| < d

2

12if |x| = d

2

0 if |x| > d2

For f [x] as defined above, the set of samples is derived by integrating f [x] overthe area of width d centered at coordinates that are integer multiples of ∆x:

1

d

Z n·∆x+d2

n·∆x− d2

1

2

µ1 + cos

∙2πx

X0+ φ

¸¶dx =

1

2d

ÃZ n·∆x+ d2

n·∆x− d2

dx+

Z n·∆x+d2

n·∆x− d2

cos

∙2πx

X0+ φ

¸dx

!

=1

2d

∙µn ·∆x+

d

2

¶−µn ·∆x− d

2

¶¸+1

2d

sinh2πxX0+ φ

i2πX0

¯̄̄̄¯̄x=n·∆x+d

2

x=n·∆x−d2

=1

2+1

2d

sinh2πn · ∆x

X0+ πd

X0+ φ

i− sin

h2πn · ∆x

X0− πd

X0+ φ

i³2πX0

´By defining α = 2πn · ∆x

X0+ φ and β = πd

X0, and by using the trigonometric identity:

sin [α+ β]− sin [α− β] = 2 cosα sinβ,

we find an expression for the integral over the detector area:

fs [n] =1

2+1

2d

⎛⎝2 cos ∙2πn · ∆x

X0+ φ

¸ sin h πdX0

i2πX0

⎞⎠≡ 12+1

2cos

∙2πn · ∆x

X0+ φ

¸SINC

∙d

X0

¸where SINC [α] ≡ sin[πα]

πα:

Page 9: Chapter 13 Review of Sampling - College of Science | RIT

13.4 REALISTIC SAMPLING — AVERAGING BY THE DETECTOR277

Graph of SINC [x] ≡ sin[πx]πx

Note that for constant functions X0 =∞ and SINC³

dX0

´→ 1; uniform weighted

averaging has no effect on constant inputs. The samples of cosine of period X0

obtained with sampling interval ∆x in the two cases are:

Realistic:fs [n] =1

2·µ1 +

1

2SINC

∙d

X0

¸· cos

∙2πn · ∆x

X0+ φ

¸¶Ideal : fs [n] =

1

2·µ1 + cos

∙2n

µ∆x

X0

¶+ φ

¸¶where d is the width of the detector. The amplitude of the realistic case is mul-

tiplied by a factor of SINCh

dX0

i, which is less than unity everywhere except at the

origin, , i.e., where d = 0 or X0 = ∞. As the detector size increases relative to thespatial period of the cosine ( i.e., as d

X0increases) , then SINC

hdX0

i→ 0 and the

modulation of the sinusoid decreases.

The modulation of the image of a sine-wave of period X0, or spatial frequencyξ = 1

X0, is reduced by a factor SINC

hdX0

i= SINC [dξ0].

Example of Reduced Modulation due to Prefiltering

The input function f [x] has a period of 128 units with two periods plotted. It is thesum of six sinusoidal components plus a constant:

f [x] =1

2+1

2

6Xn=1

(−1)n−1

nsin

∙2π(2n− 1)x256

¸.

Page 10: Chapter 13 Review of Sampling - College of Science | RIT

278 CHAPTER 13 REVIEW OF SAMPLING

The periods of the component sinusoids are:

X1 =128

1units =⇒ ξ1 =

1

128

cyclesunit

' 0.0078cyclesunit

X2 =128

3units ' 42.7 units =⇒ ξ2 =

3

128

cyclesunit

' 0.023cyclesunit

X3 =128

5units = 25.6 units =⇒ ξ3 =

5

128

cyclesunit

' 0.039cyclesunit

X4 =128

7units ' 18.3 units =⇒ ξ4 =

7

128

cyclesunit

' 0.055cyclesunit

X5 =128

9units ' 14.2 units =⇒ ξ4 =

9

128

cyclesunit

' 0.070cyclesunit

X6 =128

11units ' 11.7 units =⇒ ξ4 =

11

128

cyclesunit

' 0.086cyclesunit

The constant bias of 0.5 ensures that the function is positive. The first sinusoidalcomponent (X01 = 128 units) is the fundamental and carries most of the modulationof the image; the other components (the higher harmonics) have less amplitude. Thespatial frequency of each component is much less than the Nyquist limit of 0.5.

SINC

∙d

X01

¸= SINC [dξ1] = SINC

∙8 · 1128

¸' 0.994

SINC

∙d

X02

¸= SINC [dξ2] = SINC

∙8 · 3128

¸' 0.943

SINC

∙d

X03

¸= SINC [dξ3] = SINC

∙8 · 5128

¸' 0.847

SINC

∙d

X04

¸= SINC [dξ4] = SINC

∙8 · 7128

¸' 0.714

SINC

∙d

X05

¸= SINC [dξ5] = SINC

∙8 · 9128

¸' 0.555

SINC

∙d

X06

¸= SINC [dξ6] = SINC

∙8 · 11128

¸' 0.385

Note that the modulation of sinusoidal components with shorter periods (higherfrequencies) are diminished more severely by the averaging. A set of prefiltered imagesfor several different averaging widths is shown on a following page. If the detectorwidth is 32 units, the resulting modulations are:

Page 11: Chapter 13 Review of Sampling - College of Science | RIT

13.4 REALISTIC SAMPLING — AVERAGING BY THE DETECTOR279

SINC [dξ1] = SINC

∙32 · 1

128

¸' 0.900

SINC [dξ2] = SINC

∙32 · 3

128

¸' 0.300

SINC [dξ3] ' −0.180SINC [dξ4] ' −0.129SINC [dξ5] ' −0.100SINC [dξ6] ' +0.082

Note that the components with periods X04 and X05 have negative modulation,, i.e., fmax < fmin. The contrast of those components is reversed. As shown, thesampled image looks like a sawtooth with a period of 128 units.

If the detector size is 128, each component is averaged over an integral number ofperiods and the result is just the constant bias; the modulation of the output is zero:

SINC [dξ1] = SINC

∙128

128

¸= SINC [1] = 0

SINC [dξ2] = SINC

∙128· 7

42

¸= SINC [3] = 0

For a detector width of 170 units, the modulations are:

SINC [dξ1] = SINC

∙170 · 1

128

¸' −0.206

SINC [dξ2] = SINC

∙170 · 3

128

¸' −0.004

SINC [dξ3] = SINC

∙170 · 5

128

¸' +0.043

SINC [dξ4] = SINC

∙170 · 7

128

¸' −0.028

SINC [dξ5] ' −0.004SINC [dξ6] ' +0.021

Because the first (largest amplitude) sinusoidal component has negative modula-tion, so does the resulting image. The overall image contrast is reversed; darker areasof the input become brighter in the image.

Page 12: Chapter 13 Review of Sampling - College of Science | RIT

280 CHAPTER 13 REVIEW OF SAMPLING

Illustration of the reduction in modulation due to “prefiltering”: (a) input functionf [n]; (b) result of prefiltering with uniform averagers of width d = 0, d = X0

16, and

d = X0

8; (c) magnified view of (b), showing the change in the signal; (d) result

offiltering with uniform averagers of width d = X0

2, d = X0, and d = X0

0.75, showing

the “contrast reversal” in the last case.