Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Image Processing & Antialiasing Part II (Aliasing, Sampling, Convolution, and Filtering)

Similar presentations


Presentation on theme: "CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Image Processing & Antialiasing Part II (Aliasing, Sampling, Convolution, and Filtering)"— Presentation transcript:

1 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Image Processing & Antialiasing Part II (Aliasing, Sampling, Convolution, and Filtering)

2 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Overview  Example Applications  Jaggies & Aliasing  Sampling & Duals  Convolution  Filtering  Scaling  Reconstruction  Scaling, continued  Implementation 9/19/2013 Outline 2/51

3 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013  “Jaggies” an informal name for artifacts from poorly representing continuous geometry by a discrete 2D grid of pixels – a form of aliasing (later…)  Jaggies are a manifestation of sampling error and loss of information (aliasing of high frequency components by low frequency ones)  Effect of jaggies can be reduced by anti- aliasing, which smoothes out the pixels around the jaggies by averaging  Shades of gray instead of sharp black/white transitions  Diminishes HVS’ response to sharp transitions (Mach banding) Jaggies & Aliasing 3/51

4 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Midpoint algorithm: in each column, pick the pixel with the closest center to the line  A form of point sampling: sample the line at each of the integer X values  Pick a single pixel to represent the line’s intensity, full on or full off  Doubling resolution in x and y only lessens the problem, but costs 4 times memory, bandwidth, and scan conversion time!  Note: This works for -1 < slope < 1, use rows instead of columns for the other case or there will be gaps in the line 9/19/2013 Representing lines: Point sampling, single pixel Approximating same line at 2x the resolution Line approximation using point sampling 4/51

5 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Represent the line as a unit width rectangle, use multiple pixels overlapping the rectangle (for now we think of pixels as squares)  Instead of full on/off, calculate each pixel intensity proportional to the area covered by the unit rectangle  A form of unweighted area sampling – stay tuned:  Only pixels covered by primitive can contribute  Distance of pixel center to line doesn’t matter  Typically have more than one pixel per column so can go gradually from dark for pixels covered by the line to white background; the more area of overlap, the darker the pixel 9/19/2013 Representing lines: Area sampling 5/51

6 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Apply a unweighted or weighted average to each sample and it’s neighbors  Example: filtering for student height or weight – give each sample equal weight or diminish influence of samples further away  Weight function gives weight for incremental area centered at  The volume of a filter function needs to be 1 to preserve overall brightness, so W =1 over its “support”, the area it covers, 0 elsewhere 9/19/2013 Filtering as form of averaging: filter is a weighting function Post-filtered samples (decreases contrast between adjacent pixels): red = added value, light blue is subtracted area 6/51 Weight function Pre-Filtered samples

7 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 “Box Filter” Represents Unweighted Area Sampling 7/51

8 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 “Cone Filter” for Weighted Area Sampling 8/51

9 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Weighted Area Sampling (Continued) W 2-unit circular support of filter Pixel center (+) Area of overlap between support and primitive Differential area dA 2 Primitive Differential area dA 1 9/51

10 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  This simplistic scan conversion algorithm only asks if a mathematical point is inside the primitive or not  Bad for sub-pixel detail which is very common in high-quality rendering where there may be many more micro-polygons than pixels! 9/19/2013 Another Look at Point Sampling – Even Box Filter is Better! Point-sampling problems. Samples are shown as black dots. Object A and C are sampled, but corresponding objects B and D are not. A B C D 10/51

11 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Box filter  Support: 1 pixel  Sets intensity proportional to area of overlap  Creates “winking” of adjacent pixels as a small triangle translates 9/19/2013 Another Look at Unweighted Area Sampling: Box filter (b) Unweighted area sampling. (a) All sub-areas in the pixel are weighted equally. (b) Changes in computed intensities as an object moves between pixels. 11/51

12 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Pyramid filter  Support: 1 pixel  Approximates circular cone to emphasize area of overlap close to center of pixel 9/19/2013 Another Look at Weighted Area Sampling: Pyramid filter Weighted area sampling. (a) sub-areas in the pixel are weighted differently as a function of distance to the center of the pixel. (b) Changes in computed intensities as an object moves between pixels. (b) 12/51

13 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© (b)  Cone filter  Support: 2 pixels  Greater smoothness in the changes of intensity 9/19/2013 Another Look at Weighted Area Sampling: Cone filter Weighted area sampling with overlap. (a) Typical weighting function. (b) Changes in computed intensities as an object moves between pixels. 13/51

14 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© for each sample point p: //p need not be integer! place filter centered over p for each pixel q under filter: weight = filter value over q p.intensity += weight * q.intensity 9/19/2013 Pseudocode and Results Anti-aliased Aliased Related phenomenon: Moire patterns 14/51 “Crawlie Demo”Crawlie Demo

15 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Anti-Aliasing Example Close-up of original, aliased render Blur filter – weighted average of neighboring pixels Supersampling - sample multiple points within a given pixel and average the result Supersampling and Blurring Antialiasing Techniques: Checkerboard with Supersampling 15/51

16 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Overview  Example Applications  Jaggies & Aliasing  Sampling & Duals  Convolution  Filtering  Scaling  Reconstruction  Scaling, continued  Implementation 9/19/2013 Outline 16/51

17 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Easier to discuss aliasing and anti-aliasing of images and image scaling than of rendering anti-aliased geometric primitives - return at end of this unit  Need to do a brief intro to signal processing, since an image can be thought of as a sequence of scan lines, each displaying continuous intensity signals (photograph on fine-grain film) or discrete signals (pixels captured by a digital camera)  Signals are composed of combinations of waves (acoustical waves varying in time for sound, light waves varying intensity in 2D space for images)  Signals are complex waveforms but they can be decomposed into combinations of simpler waveforms (sines and cosines) of varying frequency, amplitude and phase: Fourier synthesis 9/19/201317/51 Aliasing and Anti-Aliasing: Intro to Signal Processing

18 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Scan converting an image is digitizing (sampling) a series of continuous intensity functions, one per scan line.  We will use single scan lines for simplicity, but everything still applies to full images 9/19/2013 Sampling and Scaling of Images (images courtesy of George Wolburg, Columbia University, in 2nd Edition Computer Graphics: P&P) Scan line from synthetic scene Scan line from natural scene 18/51

19 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 The Sampling/Reconstruction/Display Pipeline – overview 19/51

20 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Fourier Waveform Synthesis – Approximate a Continuous Signal Approximation of scan line signal from image improves with addition of more sine waves  Any signal can be approximated by summing sine (and cosine) waves of different frequencies, phases, and amplitudes  A signal has 2 representations. We’re familiar with the spatial domain, but every signal also can be represented in the frequency domain 20/51

21 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  A vibrating string creates a pressure wave with multiple frequency components  Intensity/volume of sound is related to amplitudes of components of pressure wave  Lowest frequency is “fundamental frequency” 9/19/2013 Digression: Music  Integer multiples of the fundamental frequency are called “harmonics” or “overtones” (non-integral multiples also exist)  Power of two multiples of the fundamental frequency are called “octaves” For more, applets to interact with these concepts: 21/51 Labels show 1/f -- the wavelength

22 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Easier to visualize signals and filtering/averaging in the frequency domain  Many problems are easier solved by transforming to another problem (an untransforming!)  Characterize a signal by its frequency spectrum showing amplitudes of component waveforms  Signal and frequency domains are duals and represent identical information.  Easier to filter in frequency domain than in signal domain, as we shall see.  Take a familiar problem: multiplication of numbers  Can take logarithm of number, perform operations on log(number), then take antilogarithm)  Dual of multiplication is addition in logarithmic “space” If ab=c then log(a) + log(b) = log(c)  This “invertible transformation” makes slide-rules such effective tools for multiplication: manipulating sliders corresponds to manipulating numbers via their logs 9/19/2013 Analogous Operations, Duals 22/51

23 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Sine wave is characterized by amplitude and frequency  Frequency of a sine wave is number of cycles per second for audio, or number of cycles per unit length (e.g., inter-pixel distance) for image scan lines  Can characterize any waveform by enumerating amplitude and frequency of all its component sine waves (Fourier transform – see chapter 18 in book)  This can be plotted as a “frequency spectrum”, a.k.a. power spectrum, (we ignore negative frequencies, but they are needed for mathematical correctness) To see spatial and frequency domains of simple signals: ory/edu/brown/cs/exploratories/applets/fft1DApp/1d_fast_f ourier_transform_guide.html ory/edu/brown/cs/exploratories/applets/fft1DApp/1d_fast_f ourier_transform_guide.html 9/19/2013 Frequency Spectrum of a Signal Signal DomainFrequency Domain 23/51

24 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Sine waves in 2D  Let white be max positive amplitude, black max negative amplitude 9/19/2013 Images: Hays Low Frequency Higher Frequency (Harmonic – integer multiple) 24/51

25 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Simple Fourier Synthesis example (1/2)  example : g(t) = sin(2πf t) + (1/3)sin(2π(3f) t) = + Slides: Hays 9/19/201325/51

26 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© f(x) x Original Function Partial approximation with 2 cosines Partial approximation with 3 cosines Partial approximation with 4 cosines Approximation with 5 cosines We are just summing waves to get bolded blue function to approximate the red signal 9/19/2013 Simple Fourier Synthesis example (2/2)  Approximate signal using sines and cosines Spatial domain 26/51

27 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  In order to capture all frequencies in a signal, we must sample at a rate that is higher than 2 times the highest frequency (with a non-zero value from the Fourier transformation) in the signal (the Nyquist limit).  Here is an approximate analog sine wave:  The sine wave sampled at an acceptable rate (4 times the highest frequency):  Reconstructed wave based on these samples: 9/19/2013 Sampling: The Nyquist Limit 27/51

28 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Aliasing occurs when we sample a signal at less than twice maximum frequency  Here is our analog sine wave again:  Here is the sine wave sampled at too low a rate:  Here is the reconstructed wave based on these samples:  The reconstruction isn’t even close! 9/19/2013 Aliasing: Know Thine Enemy 28/51

29 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Ever seen tires spin in a movie? Have you ever noticed that sometimes, they seem to be spinning backwards?  It’s because the video frame-rate is lower than twice the frequency at which the wheels spin. This is temporal aliasing!  You see this a lot in movies because the effect is so striking. It’s known as the stage-coach effect.  Porsche Dyno Test Porsche Dyno Test 9/19/2013 Temporal Aliasing: Another Sampling Error 29/51

30 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Sampling right at the Nyquist limit can also be problematic  Here is our perfect analog sine wave again:  Here is the sine wave sampled at the Nyquist limit. This time it works fine:  Here is the same sine wave sampled at the Nyquist limit, with the sample points shifted. Now we get no signal:  For an applet dedicated to illustrating the Nyquist Limit: 9/19/2013 Sampling at the Nyquist Limit y/edu/brown/cs/exploratories/applets/nyquist/nyquist_limit_gu ide.html 30/51

31 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Aliasing is shown in bottom diagrams on previous slides – Signals that are sampled at too low a rate can reconstruct high frequencies as low frequencies  These low frequencies are “aliases” of high frequencies  The low sampling rate data could not adequately represent the high frequency components, so it represented them incorrectly, as low frequencies  So, we just sample above the Nyquist limit, right?  Regrettably, we can’t always do that  What about this square wave signal? just a test pattern of alternating black/white bars  Let’s try using Fourier Synthesis 9/19/2013 The Enemy is Recognized Number of sine waves: 31/51

32 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Infinite Frequencies 32/51

33 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  The more high frequencies we pre-filter out, the lower the sampling frequency needed but the less the filtered signal resembles original.  Note: pre-filtering is often just abbreviated as filtering, but the prefix “pre” helps remind us that post-filtering (i.e., another stage of filtering after image computation or transformation) is also practiced. If post- filtering is done on reconstruction of samples of original signal, it will blur in the aliases present in the corrupted reconstruction! 9/19/2013 Infinite Frequencies 33/51

34 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© This doesn’t look right at all. There are no stripes and the image now has a blacker average intensity 9/19/2013 Scale Aliasing, or “Why do we have to pre-filter?” Original Image Image with sample points marked Image scaled using point samples 34/51

35 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Better, but not perfect… 9/19/2013 Scale Aliasing II, or “Close, but no cigar?” Original Image Prefiltered image with samples marked Prefiltered image scaled 35/51

36 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Good: The pre-filtered scaled image now has same overall brightness  Bad: still no stripes  Filter removed “high frequencies” from image  discontinuities that were stripes  Given number of points to represent image once scaled, not enough points to represent high frequencies; even higher sampling rate doesn’t help…  Nyquist limit says that we can’t represent frequencies higher than ½ our sampling rate, thus can’t do better than this blurred approximation 9/19/2013 Scale Aliasing III, or “Why is it still wrong?” 36/51

37 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Overview  Example Applications  Jaggies & Aliasing  Sampling & Duals  Convolution  Filtering  Scaling  Reconstruction  Scaling, continued  Implementation 9/19/2013 Outline 37/51

38 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Remember filtering is just (weighted) averaging of samples in a neighborhood  How is it done in practice? Just a nested for loop through all the sample points  either sample at integer pixel locations or in between (e.g., for image up-scaling)  based on the theory of signal convolution – the convolution integral  we’ll use a finite approximation to that integral  First we’ll low-pass pre-filter to remove (as much as possible) un-representable frequencies to minimize aliases (doable in most non-pathological cases for images, not for rendering, where we’ll use “supersampling” and post-filtering – lecture IP-IV)  Second, there will be another form of filtering when the samples are “reconstructed” as a continuous signal approximating the original signal  in the case of raster graphics, reconstruction combines  the h/w generation of pixels from pixel values as an image that feeds  the perceptual apparatus of the HVS (Human Visual System) which typically smoothes out discontinuities (spatially and temporally), a kind of integration 9/19/201338/51 Filtering as an Application of the Convolution Integral

39 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Low-Pass Filtering to Eliminate High Frequencies (shown for one scan line in Spatial Domain) 39/51

40 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Ideal Low-Pass Filtering (Frequency Domain) 40/51 … …

41 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  This is the type of convolution we will be using once we begin coding  If we evenly sample a function, get an array of point samples, e.g., (R,G, B) triples as color intensity values  Some mathematicians think of an array of numbers as a function. Think this way for the next few slides!  The larger the array (the more samples/unit interval) the more accurate the representation of the function and the better our ability to anti-alias and improve the reconstruction 9/19/201341/51 Discrete convolution – Function as an Array [ 1.2, 0, -1.2, 0, 1.2, 0, -1.2 ]

42 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Have two arrays (functions), f and g, and we assign g as our “filter”. For the sake of convenience, force the filter to have an odd number of points so that there is a center  Once we are done with our convolution, we will produce a new array (function)  You’ll do this for blur and edge detection, as well as for image scaling  Take the filter, and line up the center point of the filter with each element, i, of f. Multiply each pair of elements and sum the products. Assign this value to element i of the output array  When we are scaling, this procedure will change slightly because where we center the filter and where our value goes will be different!  One hiccup: The output array will be slightly larger than our initial array because we start our multiplication/sum process at the edges, where it will generate a non-zero result  It is easier to see! 9/19/201342/51 Discrete Convolution for Filtering

43 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/201343/51 Discrete Convolution – Visually (1/2) Function, f Function, g, a box filter [ 1.2, 0, -1.2, 0, 1.2, 0, -1.2 ] [ ⅓, ⅓, ⅓]

44 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/201344/51 Discrete Convolution – Visually (2/2) [ 1.2, 0, -1.2, 0, 1.2, 0, -1.2 ] [ ⅓, ⅓, ⅓ ] [.4 _ _ _ _ _ _ _ _ ] [ 1.2, 0, -1.2, 0, 1.2, 0, -1.2 ] [ ⅓, ⅓, ⅓] [.4.4 _ _ _ _ _ _ _ ] [ 1.2, 0, -1.2, 0, 1.2, 0, -1.2 ] [ ⅓, ⅓, ⅓ ] [ _ _ _ _ _ _ ] [ 1.2, 0, -1.2, 0, 1.2, 0, -1.2 ] [ ⅓, ⅓, ⅓ ] [ _ _ _ _ _ ] Output [.3,,.3]

45 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Think of an array as a function  We take two arrays and generate a third  We “slide” the filter along the other array and at each element, calculate a value by multiplying the pairs and summing the products to do the (weighted) averaging  Our output array will be slightly larger than our input array if we start too far over the edges. We can (and will) ignore this for image processing and just take “inner” part of the array  Another hiccup to be aware of: Our process has an additional step if our filter is not symmetric. We will mention this more in the coming slides. Don’t worry too much about it though, in this course most filters will be symmetric 9/19/201345/51 Discrete Convolution -- Review

46 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Convolution is a process that takes two function, f and g, and produces a new function h.  When you create a function you need to define it's value for each input, i.e. h(x) = ?  For convolution, h(x) equals the integral of the product of signal f and filter g, centered at x.  This should sound very similar to our discrete notion of convolution (integrals are like sums)  You can think of convolution as sliding g over f to produce h because as we shift the center of g, we evaluate h at a new point, x  in theory, an infinite number of x’s; in practice for discrete convolution, a finite number of x’s. We’ll have to figure out where those should be in the original image, and that will differ for up-scaling and down-scaling, as a function of scale factor 9/19/201346/51 What is (Continuous) Convolution?

47 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Convolving signal with filter function  Changing variable of integration to be, ranging from 0 to ±∞ starting at x 9/19/2013 Convolution Mathematically (1/2) 47/51 Center filter g at x Multiply the pairs Integrate (sum) the products Exactly what we were doing, just in a formula!

48 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Convolving signal f(x) with filter function g(x):  At each point x, h(x) is integral of product f of and g, except g is flipped and translated so its origin is at x  In practice, f or g is often an even function (symmetric about the y-axis) and we don’t need to flip  If g(x) has finite support, it does a weighted average centered at x  f(x) (blue signal) convolved by g(x) (red filter) to get result h(x) (black signal)  f(x) and g(x) are box functions  Each point on black signal is result of an integral, represented by the area under the product of f(x) and g(x) (yellow area)  Note: in filtered signal h(x), discontinuities of f(x) are smoothed out and the base is broadened 9/19/2013 Convolution Mathematically (2/2) eeSoftware/repository/edu/brown/cs/expl oratories/applets/convolution/convolution _guide.html 48/51

49 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Convolution is a lot like multiplication Try the applet: applets/twoBoxConvolution/two_box_convolution_guide.html 9/19/2013 Simple Convolution Example * 1111 × /51

50 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Properties of Convolution 50/51

51 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Duals Sinc in spatial domain corresponds to box/pulse in frequency domain Truncated sinc in spatial domain corresponds to ringing pulse in frequency domain – decent approximation to perfect pulse 51/51

52 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Spatial domainFrequency domain BoxSinc TriangleSinc 2 Finite GaussianGaussian Bad filter in practice: gradual attenuation, negative lobes, infinite extent, all corrupting signal. But still beats point sampling! Common Filters and Their Duals 52/51

53 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© SpatialFrequency MultiplicationConvolution Multiplication BoxSinc Box 9/19/2013 Duals 53/51

54 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Overview  Example Applications  Jaggies & Aliasing  Sampling & Duals  Convolution  Filtering  Scaling  Reconstruction  Scaling, continued  Implementation 9/19/2013 Outline 54/51

55 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  In theory sinc has infinite extent, however small the contributions and negative lobes, but weights contributions at the center most heavily.  Practically, sinc is decently approximated with gaussian (normal) distribution, or even triangle, with finite extents and weights greater than or equal to zero. 9/19/2013 Low-Pass Filtering: Convolving with sinc Original signal Sinc filter Filtered signal Filter operation at origin shown as black dot 55/51

56 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  Select points at which to sample, e.g., pixel centers  Slide the filter over each successive sample point and compute convolution integral at that point (the area under product curve)  This is weighted average of current pixel and its nearby neighbors  Most useful graphics filters are symmetric about their origin and fall off rapidly from their center  Weighted average is value of pixel for filtered image  Our illustrations are 2D, but for pixels one should think of sinc as three-dimensional weighting map  Of course, we don’t actually compute the integral, we merely compute discrete values of filter function and do discrete multiplication and summing to approximate.  Term “filter” used strictly in signal-processing sense (filter can also used to mean arbitrary transformations of an image, like in Photoshop) 9/19/2013 What Does Filtering/Convolution Do? Sinc in 3D 56/51

57 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 Filtering Summary 57/51

58 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©  To get low-pass filtering (i.e., filter out high frequencies), we often use convolution with triangle function in spatial domain to approximate ideal sinc  Properties of triangle function:  Easy to compute, unlike sinc, which has an infinite support (or even a Gaussian approximation to sinc)  Its dual, sinc 2, is acceptable approximation to a box function although it has infinite extent (see slide 36)  Will cause inaccurate representation of all frequencies and therefore some degree of corruption/aliasing must occur.  Not as bad as using box as a filter with sinc as its dual in the frequency domain  In other words, weighted area sampling of any kind, providing it is roughly cone- shaped, is better than unweighted area sampling with a box filter, which is better in turn than point sampling 9/19/2013 Filtering Summary 58/51

59 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam©9/19/2013 The Filtering Pipeline 59/51


Download ppt "CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam© Image Processing & Antialiasing Part II (Aliasing, Sampling, Convolution, and Filtering)"

Similar presentations


Ads by Google