Logistics Checkpoint 1 all graded Intro to Sampling Theory Grades / comments on mycourses Project Proposals due tonight Please place in mycourses dropbox Questions? Plan for today Approaches to modeling in CG Sampling Theory How does one describe reality? Empirical -- Use measured data Fixed model Procedural Modeling Physical simulation Heuristic Sampling Theory Sampling in modeling The world is continuous Like it or not, CG is discrete. We work using a discrete array of pixels We use discrete values for color We use discrete arrays and subdivisions for specifying textures and surfaces Process of going from continuous to Digibotics Laser Scanner 3D Scanner discrete is called sampling. 1
Sampling in reflectance Sampling in modeling modeling goniometer Surface subdivision Sampling in textures Sampling in textures Point sampled textures Filtered textures www.sharkyextreme.com www.sharkyextreme.com Sampling in image generation Sampling Theory Signal - function that conveys information Audio signal (1D - function of time) Image (2D - function of space) Continuous vs. Discrete Continuous - defined for all values in range Discrete - defined for a set of discrete points in range. 2
Sampling Theory Sampling Theory Point Sampling start with continuous signal calculate values of signal at discrete, evenly spaced points (sampling) convert back to continuous signal for display or output (reconstruction) Foley/VanDam Sampling Theory Sampling Theory Sampling Rate = number of samples per unit Sampling can be described as creating a set of values representing a function = 1 evaluated at evenly spaced samples f � f n f ( i ) i 0 , 1 , 2 , , n K = � = Example -- CD Audio Δ = interval between samples = range / n. sampling rate of 44,100 samples/sec Δ = 1 sample every 2.26x10 -5 seconds Issues: Sampling Theory Important features of a scene may be Rich mathematical foundation for missed sampling theory If view changes slightly or objects move Hope to give an “intuitive” notion of slightly, objects may move in and out of these mathematical concepts visibility. To fix, sample at a higher rate, but how high does it need to be? 3
Sampling Theory Sampling Theory Spatial vs frequency domains Most well behaved functions can be described as a sum of sin waves (possibly offset) at various frequencies Frequency specturm - a function by the contribution (and offset) at each frequency is describing the function in the frequency domain Higher frequencies equate to greater detail Foley/VanDam Sampling Theory Sampling Theory Interactive wave builder Annoying audio applet 1 Fourier Synthesis -- Graphic Equalizer http://www.sunsite.ubc.ca/LivingMathe http://www.phy.ntnu.edu.tw/ntnujava/vie matics/V001N01/UBCExamples/Fourier/f wtopic.php?t=33 ourier.html Sampling Theory Sampling Theory Nyquist Theorum Example -- CD Audio A signal can be properly reconstructed if the signal sampling rate of 44,100 samples/sec is sampled at a frequency (rate) that is greater Δ = 1 sample every 2.26x10 -5 seconds than twice the highest frequency component of the signal. Using Nyquist Theorem Said another way, if you have a signal with highest frequency component of f h , you need at CDs can accurately reproduce sounds with lease 2f h samples to represent this signal frequencies as high as 22,050 Hz. accurately. 4
Sampling Theory Sampling Theory Aliasing Aliasing - example Failure to follow the Nyquist Theorum results in aliasing . Aliasing is when high frequency components of a signal appear as low frequency due to inadequate sampling. In CG: Jaggies (edges) Foley/VanDam(628) Textures Missed objects High frequencies masquerading as low frequencies Sampling Theory Anti-Aliasing Annoying Audio Applet 2 What to do in an aliasing situation Aliasing Increase your sampling rate (supersampling) Decrease the frequency range of your signal http://ptolemy.eecs.berkeley.edu/eecs20/week13/ (Filtering) aliasing.html How do we determine the contribution of each frequency on our signal? Fourier analysis Sampling Theory Fourier Transforms Given f(x) we can generate a function f(x) F(u) which indicates how much Inverse contribution each frequency u has on Fourier F(u) Fourier Transform the function f. Transform F(u) is the Fourier Transform f(x) Fourier Transform has an inverse 5
Sampling Theory Sampling Theory The Fourier transform is defined as: The Inverse Fourier transform is defined as: � � i � 2 ut i � 2 ut F ( u ) f ( t ) e dt f ( t ) F ( u ) e du � = � = � � � � � Note: the Fourier Transform is defined in the complex plane Signals in the frequency domain Sampling Theory http://www.falstad.com/fourier/ How do we calculate the Fourier Transform? Use Mathematics For discrete functions, use the Fast Fourier Transform algorithm (FFT) Break… Anti-Aliasing Supersampling Increase your sampling rate What to do in an aliasing situation Examples Increase your sampling rate Resolution in images (supersampling) Number of subdivisions in modeling Decrease the frequency range of your Number of sample points signal (Filtering) Number of rays per pixel. May not always have this luxury 6
Supersampling Anti-aliasing -- Filtering Can filter the transform to remove offending high frequencies - partial solution to anti-aliasing Removes high component frequencies from a signal. Removing high frequencies results in removing detail from the signal. Can be done in the frequency or spatial domain Wikipedia Filtering – Frequency Domain Getting rid of High Frequencies Original Spectrum Filtering -- Frequency domain Place function into frequency domain F(u) Low-Pass Filter Simple multiplication with box filter S(u), aka pulse function , band(width) limiting or low-pass filter. Spectrum with Filter 1 , when k u k � � � � S ( u ) = � 0 , elsewhere � Filtered Spectrum Suppress all frequency components above some specified cut-off point k Foley/VanDam(631) Getting Rid of High Convultion sinc Function Frequencies Filtering -- Spatial Domain Convolving with a sinc function in the spatial domain is the same as using a box filter in the Convolution (* operator) - equivalent to multiplying two Fourier transforms frequency domain FT → � h ( x ) f ( x ) g ( x ) f ( ) g ( x ) d = � = � � � � � � � Taking a weighted average of the neighborhood around each point of f , weighted by g (the ← FT -1 convolution or filter kernel ) centered at that point. Foley/VanDam (634) 7
Filtering using Convolution Convolution Original Spectrum Joy of Convolution applet Sinc Filter http://www.jhu.edu/~signals/convolve/index. Spectrum with Filter html value of filtered signal Filtered Spectrum Foley/VanDam (633) Sampling Theory Sampling Theory Anti-aliasing -- Filtering 2D Sampling Removes high component frequencies from Images are examples of sampling in 2- a signal. dimensions. Removing high frequencies results in 2D Fourier Transforms provides strength of removing detail from the signal. signals at frequencies in the horizontal and vertical directions Can be done in the frequency or spatial domain Sampling Theory Sampling Theory 2D Aliasing 2D Fourier Transform � � i 2 ( ux vy ) F ( u , v ) f ( x , y ) e � � + dxdy = � � � � � � aliased image anti-aliased image Foley/VanDam 8
Sampling Theory Sampling Theory Filtering - Convolution in 2D Castleman Castleman Sampling Theory Sampling Theory Filtering – Convolution with images Filtering – Convolution in frequency domain Image 2D FFT Filter out Filtered high 2D FFT frequencies Castleman Castleman Other Anti-aliasing Methods Anti-Aliasing Applet Pre-filtering - filtering at object precision before calculating pixel’s sample Post-filtering - supersampling (as we’ve seen) http://www.nbb.cornell.edu/neurobio/land/Ol Adaptive supersampling - sampling rate is dStudentProjects/cs490- varied, applied only when needed (changes, 96to97/anson/AntiAliasingApplet/index.html edges, small items) Stochastic supersampling - places samples at stocastically determined positions rather than regular grid 9
Sampling Theory Sampling Theory Summary Further Reading Digital images are discrete with finite Foley/VanDam – Chapter 14 resolution…the world is not. Digital Image Processing by Kenneth Spatial vs. Frequency domain Castleman Nyquist Theorum Glassner, Unit II (Book 1) Convolution and Filtering 2D Convolution & Filtering Questions? Remember Class Web Site: http://www.cs.rit.edu/~jmg/cgII Any questions? 10
Recommend
More recommend