Presentation is loading. Please wait.

Presentation is loading. Please wait.

Filtering Robert Lin April 29, 2004. Outline Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview.

Similar presentations


Presentation on theme: "Filtering Robert Lin April 29, 2004. Outline Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview."— Presentation transcript:

1 Filtering Robert Lin April 29, 2004

2 Outline Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview of common filters

3 Why Filter? Anti-aliasing Signal reconstruction Remove frequencies  Remove which frequencies?  Low-pass filter: removes high frequencies (blurring)  High-pass filter: removes low frequencies (sharpens, enhance edges)  Graphics: usually want low pass filtering to remove aliasing

4 Image Filtering Modify pixels of an image based on a function of local nearby pixels Filter determines weight of a pixel

5 Filtering for Sampling Filtering can be used to determine which rays to cast for a particular pixel (e.g., cast more rays near the center) Filtering can also be used to assign weights to the rays that determine how much they contribute to the pixel color

6 Photon Filtering We can filter the radiance estimate Weight closer photons more when calculating radiance estimate Can reduce blur at sharp edges when photon count is low – good for stuff like caustics

7 Sampling and Reconstruction Given a signal such as a sine wave with frequency 1 Hz:

8 Sampling and Reconstruction We can sample the points at a uniform rate of 3 Hz and reconstruct the signal:

9 Sampling and Reconstruction We can also sample the signal at a slower rate of 2 Hz and still accurately reconstruct the signal:

10 Sampling and Reconstruction However, if we sample below 2 Hz, we don’t have enough information to reconstruct the signal, and in fact we may construct a different signal:

11 Nyquist Frequency To reconstruct a signal with frequency f, we need to sample the signal at a rate of at least 2*f, which is the Nyquist Frequency Example  CD : SR = 44,100 Hz  Nyquist Frequency = SR/2 = 22,050

12 Nyquist Frequency Sampling below the Nyquist frequency can cause aliasing – the reconstructed signal is a false representation of the original signal. We can reduce aliasing by sampling more, or sampling intelligently (last lecture). We can also use filtering to reduce aliasing.

13 How do you filter? To filter a function f(x), we use a filter function g(x) and convolute f(x) with g(x). This is the same for filtering 2D images, and the functions become functions of x and y.

14 Convolution The convolution of a function f(x) and a function g(x) (usually a filter function), is defined to be: The value of h(x) at each point is the integral of the product of f(x) with the filter function g(x) flipped about the y axis and shifted so that its origin is at that point This is taking a weighted average of points near f(x), where g(x) defines what the weights are.

15 Convolution Green curve is the convolution of the Red curve, f(x), and the Blue curve, g(x). The grey region indicates the product g(u) f(t – u) The convolution Is thus the area of the grey region

16 The Fourier Transform A signal can be expressed as a sum of different sine curves The Fourier Transform determines which sine waves represent the original signal

17 The Fourier Transform The Fourier Transform F(k) of a function f(x) in spatial domain is defined to be: F(k) is now in frequency domain, usually plotted with the x-axis as frequency, and the y-axis as magnitude.

18 The Fourier Transform A signal composed of two sine waves with frequency 2 Hz and 50 Hz The Fourier Transform of the signal shows these two frequencies The domain of the graph of the Fourier transform is frequency; the range is magnitude

19 The Fourier Transform

20 Space Frequency

21 The Fourier Transform The convolution of f and g is the same as multiplying the Fourier transforms of f and g: This lets us look at the frequency domain of a filter function to figure out what the filter does.

22 Frequency Domain  =  = Low-pass High-pass In the frequency domain, multiplying by a filter function removes particular frequencies

23 Low Pass Filter in Frequency Domain

24 Low Pass Filter

25 High Pass Filter

26 The Sinc Filter Spatial: sincFrequency: box

27 The Sinc Filter Perfect low-pass filter Cuts off all frequencies above a threshold Oscillates to infinity: need too many samples We use other functions similar to a sinc to filter

28 The Box Filter Spatial: BoxFrequency: sinc

29 The Box Filter Smooths out function by averaging neighbors Keeps low frequencies and reduces high frequencies (low-pass filter) Equally weights all samples In frequency domain, contains sidelobes to infinity, which can cause rings on sharp edges

30 The Tent Filter Spatial: TentFrequency: sinc squared

31 The Tent Filter Reduces high frequencies more Weights center sample more Other samples weighted linearly

32 The Gaussian Filter Spatial: GaussianFrequency: Gaussian

33 The Gaussian Filter Reduces high frequences even more No sharp edges like in box, tent Generally

34 The B-Spline Filter Each row and column of the image is represented by a B-Spline curve Each pixel is a control point

35 The B-Spline Filter original L(x,y) = 0.5 + (1 + sin( 0.01*(x*x + y*y))) order 3 order 1 order 2 order 0

36 The B-Spline Filter Bilinear Bspline

37 Conclusion Filtering is good Reduces aliasing Makes the picture pretty Very similar to sampling We filter an image by convoluting it with the filter The FT gives information about the filter Try different filters, use the one that looks good

38 References Books:  Andrew Glassner. Principles of Digital Image Synthesis.  James D. Foley, Andries van Dam, Steven K. Feiner, John F. Hughes. Computer Graphics: Principles and Practice.  Peter Shirley, R. Keith Morley. Realistic Ray Tracing.  Henrik Wann Jensen. Realistic Image Synthesis Using Photon Mapping. Websites:  http://rise.sourceforge.net/cgi-bin/makepage.cgi?Filtering  http://www.hinjang.com/gfx/gfx01.html  http://www.relisoft.com/Science/Graphics/filter.html  http://www.cg.tuwien.ac.at/courses/CG2/SS2002/SamplingAndR econstruction-new.pdf  http://w3.impa.br/~ipcg/c06/slides/main.pdf  http://redwood.ucdavis.edu/bruno/npb261/aliasing.pdf


Download ppt "Filtering Robert Lin April 29, 2004. Outline Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview."

Similar presentations


Ads by Google