filtering desingn 1
DESCRIPTION
Filtering Desingn 1TRANSCRIPT
![Page 1: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/1.jpg)
Filtering
Robert LinApril 29, 2004
![Page 2: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/2.jpg)
Outline
Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview of common filters
![Page 3: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/3.jpg)
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
![Page 4: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/4.jpg)
Image Filtering
Modify pixels of an image based on a function of local nearby pixels
Filter determines weight of a pixel
![Page 5: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/5.jpg)
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
![Page 6: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/6.jpg)
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
![Page 7: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/7.jpg)
Sampling and Reconstruction
Given a signal such as a sine wave with frequency 1 Hz:
![Page 8: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/8.jpg)
Sampling and Reconstruction
We can sample the points at a uniform rate of 3 Hz and reconstruct the signal:
![Page 9: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/9.jpg)
Sampling and Reconstruction
We can also sample the signal at a slower rate of 2 Hz and still accurately reconstruct the signal:
![Page 10: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/10.jpg)
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:
![Page 11: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/11.jpg)
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
![Page 12: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/12.jpg)
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.
![Page 13: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/13.jpg)
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.
![Page 14: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/14.jpg)
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.
h žx Ÿ= f ⊗g =+ f žu Ÿg žx u Ÿdu
![Page 15: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/15.jpg)
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
![Page 16: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/16.jpg)
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
![Page 17: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/17.jpg)
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.
![Page 18: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/18.jpg)
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
![Page 19: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/19.jpg)
The Fourier Transform
![Page 20: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/20.jpg)
The Fourier Transform
-0.02
0.03
0.08
0.13
0.18
-0.02
0.03
0.08
0.13
0.18
Space Frequency
![Page 21: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/21.jpg)
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.
![Page 22: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/22.jpg)
Frequency Domain
=
=
Low-pass
High-pass
In the frequency domain, multiplying by a filter function removes particular frequencies
![Page 23: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/23.jpg)
Low Pass Filter in Frequency Domain
![Page 24: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/24.jpg)
Low Pass Filter
![Page 25: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/25.jpg)
High Pass Filter
![Page 26: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/26.jpg)
The Sinc Filter
Spatial: sinc Frequency: box
![Page 27: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/27.jpg)
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
![Page 28: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/28.jpg)
The Box Filter
Spatial: Box Frequency: sinc
![Page 29: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/29.jpg)
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
![Page 30: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/30.jpg)
The Tent Filter
Spatial: Tent Frequency: sinc squared
![Page 31: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/31.jpg)
The Tent Filter
Reduces high frequencies more
Weights center sample more
Other samples weighted linearly
![Page 32: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/32.jpg)
The Gaussian Filter
-0.02
0.03
0.08
0.13
0.18
-0.02
0.03
0.08
0.13
0.18
Spatial: Gaussian Frequency: Gaussian
![Page 33: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/33.jpg)
The Gaussian Filter
Reduces high frequences even more
No sharp edges like in box, tent
Generally
![Page 34: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/34.jpg)
The B-Spline Filter
Each row and column of the image is represented by a B-Spline curve
Each pixel is a control point
![Page 35: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/35.jpg)
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
![Page 36: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/36.jpg)
The B-Spline Filter
Bilinear Bspline
![Page 37: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/37.jpg)
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
![Page 38: Filtering Desingn 1](https://reader035.vdocuments.us/reader035/viewer/2022070413/55cf941e550346f57b9fbe1b/html5/thumbnails/38.jpg)
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/
SamplingAndReconstruction-new.pdf http://w3.impa.br/~ipcg/c06/slides/main.pdf http://redwood.ucdavis.edu/bruno/npb261/aliasing.pdf