Unformatted text preview: Introduction to Computer Graphics
Antialiasing Towards the Ideal Line
We can only do a discrete approximation Illuminate pixels as close to the true path as
possible, consider bi-level display only
• Pixels are either lit or not lit What is a ideal pixel (point)?
A ideal pixel is not…
• A box
• A disk
A ideal pixel is a point
• It has no dimension
• It occupies no area
• It cannot be seen
• It can have a coordinate A ideal pixel is more than a point, it is a sample Samples
Most things in the real world are continuous
Everything in a computer is discrete
The process of mapping a continuous function to a
discrete one is called sampling
The process of mapping a continuous variable to a
discrete one is called quantization
Rendering an image requires sampling and
Ideally, one want to eliminate the aliasing in
Practically, one can weaken the aliasing in
images. Samples Samples Does anti-aliasing need programming?
The programming for anti-aliasing is included in
The normal graphics applications do not need
programming for this.
programming Signal Theory Intensity Convert spatial signal to frequency domain Pixel position across scanline
Example from Foley, van Dam, Feiner, and Hughes Signal Theory
Represent spatial signal as sum of sine waves
(varying frequency and phase shift)
Very commonly used to represent sound
“spectrum” Signal Theory Signal Theory The essential of Fourier Analysis
Consider the dot product of two 3D vectors.
( x1 y1 x2 z1 ) y 2 = x1 x 2 + y1 y 2 + z1 z 2
z 2 Consider the dot product of two nD vectors. (x 1
2 x12 2
1 x2 1
...... x n )
= x1 x12 + x 1 x 2 + ......x 1 x n
...... x2 n The essential of Fourier Analysis
Consider the integral of two functions, and recall
the infinite dimension vectors.
the ∫ +∞ −∞ f ( x) g ( x)dx = f ( x) • g ( x)
T The integral of two functions is the dot product of
the two infinite dimension vectors.
the Signal or Vector?
Consider this function: + ∞ x = 0
δ ( x) = 0 x≠0
Can a signal be represented as the following?
+∞ f ( x' ) = ∫ f ( x)δ ( x − x' )dx
−∞ The essential of Fourier Analysis
Consider one interesting property of cosine (or sine)
functions. ∫ +∞ −∞ iff cos ω1 x ⋅ cos ω2 x ⋅ dx = 0 ω1 ≠ ω2 If the frequencies are different for these two cosine
function, these two infinite vectors are vertical to each
other. The essential of Fourier Analysis
All cosine functions with different frequencies
construct one orthogonal vector basis for infinite
dimension vector space.
All kinds of functions can be represented as the
linear combination of this vector basis.
linear The essential of Fourier Analysis
Now consider the purpose of the Fourier Transformation. +∞ F (ω ) = ∫ f ( x) cos(ωx)dx
−∞ Only two vectors with the same frequency can yield the non-zero
The purpose of Fourier Transformation is to extract the extent of each
basic vector (cosine function) in this given function f(x) ( a singal).
How about the converse transformation?
How Fourier Transform
Examples of spatial and frequency domains Fourier Transform
Examples of spatial and frequency domains Nyquist Sampling Theorem
The ideal samples of a continuous function
contain all the information in the original function
if and only if the continuous function is sampled
at a frequency greater than twice the highest
frequency in the function
frequency Nyquist Rate
The lower bound on the sampling rate equals
twice the highest frequency component in the
This lower bound is the Nyquist Rate Band-limited Signals
If you know a function contains no components of
frequencies higher than x
• Band-limited implies original function will not require any
ideal functions with frequencies greater than x
• This facilitates reconstruction Flaws with Nyquist Rate
Samples may not align with peaks Flaws with Nyquist Rate
When sampling below Nyquist Rate, resulting
signal looks like a lower-frequency one
• With no knowledge of band-limits, samples could have
been derived from signal of higher frequency
been Original Signal & Sampled Signal Original Signal & Sampled Signal
f A f
A f Nyquist theory explain in frequency domain. f How about the sampling for an ideal
y=y0 y0 x0 x x0 x This is an impact function. How about the sampling for an ideal
1 t f
The sampling rate must be infinite number for non-aliasing sampling. What can we do for this difficulty?
Low pass signal
Fourier Transformation t
The sampling rate can be finite, but the line is much wider. f Summary of aliasing.
(1) Sampling theory tells us aliasing is caused by frequencies
being present above the Nyquist limit.
(2) The aliasing is also caused by the approximate sampling
location. Summary of aliasing.
Ideal solution : band-pass filter to remove high frequencies. This function is an impractical filter. Sampling Pipeline Sampling Pipeline Line Segments
We tried to sample a line segment so it would map
to a 2D raster display
We quantized the pixel values to 0 or 1
We saw stair steps, or jaggies Antialiasing lines.
Obvious : Need a grey level and area sample display
in order to remove aliasing.
in 1 pixel Price to be paid : trade off spatial resolution
• Line appears more ‘blurred’, it’s exact position is no longer as well
• In practice : contrast of lines much reduced.
In Line Segments
Instead, quantize to many shades
But what sampling algorithm is used? Antialiasing by area sampling.
Draw line as thin rectangle.
Calculate area of square pixel covered by line
Calculate Area Sampling
Shade pixels according to the area covered by thickened
This is unweighted area sampling
This unweighted A rough approximation formulated by dividing each pixel
into a finer grid of pixels
into Unweighted Area Sampling
Primitive cannot affect intensity of pixel if it does
not intersect the pixel
Equal areas cause equal intensity, regardless of
distance from pixel center to area
distance Weighted Area Sampling
Unweighted sampling colors two pixels identically
when the primitive cuts the same area through
the two pixels
Intuitively, pixel cut through the center should be
more heavily weighted than one cut along
corner Weighted Area Sampling
Weighting function, W(x,y)
• specifies the contribution of primitive passing through
the point (x, y) from pixel center
Intensity W(x,y) x Weighted area filtering
Easy to compute, symmetrical. Lines are same distance
from pixel centre, but
area of pixel covered is
very different in the square case Weighted area filtering.
Diameter is 2 pixels, so overlap occurs
• Ensures all of the grid is covered Area is normalised
Only need to know distance from pixel centre to
Gupta-Sproull algorithm. Summary of antialiasing lines
Use square unweighted average filter
• Poor representation of line. Weighted average filter better
• Symmetrical, only need to know distance
• Use decision variable calculated in Bresenham.
• Gupta-Sproull algorithm. Anti-Aliasing in Image
Because the area-sampling lines have no clear
boundaries, it is difficult to perform region filling.
Is there a method which can combine anti-aliasing
and region filling?
An image is a 2D function I(x, y) that specifies
intensity for each point (x, y)
intensity Sampling and Image
Our goal is to convert the continuous image to a
discrete set of samples
The graphics system’s display hardware will
attempt to reconvert the samples into a
continuous image: reconstruction
reconstruction Point Sampling an Image
Simplest sampling is on a grid
solely on value
at grid points Point Sampling
Multiply sample grid by image intensity to obtain a
discrete set of points, or samples.
discrete Sampling Geometry Sampling Errors
Some objects missed entirely, others poorly
sampled Fixing Sampling Errors
• Take more than one sample for each pixel and combine
– How many
– How do we
lost? 150x15 to 100x10
200x20 to 100x10
300x30 to 100x10
400x40 to 100x10 How is this done today?
Full Screen Antialiasing
• OpenGL: render image 400% larger and supersample
• Direct3D: render image 400% - 1600% larger Nvidia GeForce3
• Multisampling but with fancy overlaps
– Don’t render at higher resolution
– Use one image, but combine values of neighboring
• After each pixel is rendered, write pixel value to two
different places in frame buffer
different GeForce3 - Multisampling
After rendering two copies of entire frame
• Shift pixels of Sample #2 left and up by ½ pixel
• Imagine laying Sample #2 (red) over Sample #1 (black) GeForce3 - Multisampling
Resolve the two samples into one image by
computing average between each pixel from
Sample 1 (black) and the four pixels from
Sample 2 (red) that
are 1/ sqrt(2) pixels
away GeForce3 - Multisampling No AA Multisampling GeForce3 - Multisampling • 4x Supersample Multisampling ATI NVidia comparison
ATI Radeon 8500
AA Off 2x AA NVidia GF3 Ti 500
Quincunx AA 3dfx
• 2- or 4-frame shift and average Tradeoffs? ...
View Full Document
- Spring '10
- Digital Signal Processing, Pixel, sampling rate, Nyquist–Shannon sampling theorem