computergraphics
DESCRIPTION
matlTRANSCRIPT
Computer Graphics
Spring 2007, #4Anti-aliasing
Sampling problem
• For chosen technical reasons a computer screen today consists of finite area pixels with constant properties over the pixel area
• Any mathematically exact object is approximated on the screen by a set of pixels
• Any object is thus undersampled and pixels are not where they should be: aliasing
Anti-aliasing
• Typical appearance of aliasing: a straight line or edge is jagged
• Is there any way to improve the result by changing the sampling?
• In principle no: we are often truely losing information when undersampling
• Often expressed as Nyqvist’s theorem: A continuous time signal containing frequencies f ≤ B can be exactly reproduced from samples taken at sampling frequency fS > 2B.
Anti-aliasing
• Two basic principles of improving the appearance by slightly blurring the drawing: change the intensities of Bresenham pixels and neighbouring pixels– supersampling (postfiltering)
• we calculate subpixels and then integrate to obtain original pixels
– area sampling (prefiltering)• we calculate pixel intensities without pixellated
quantities
Supersampling
• Choose a finer subgrid, 2x2, 3x3, ...• Run your normal line drawing algorithm on
this finer grid.• From the result, calculate the intensity for
the original pixel
20
10 11 12
21
22
X
Y
Supersampling
• For each original pixel divided into NxN subpixels, 0 or 1 or 2 or ,.. , or N subpixels will be drawn by the line drawing algorithm. This gives us a natural choice of intensity level [0,N] for each pixel.
• We can also give a relative weight to the subpixel, eg. 2 corresponds to 2/16 = 1/8
1
2 4 2
1 2 1
12
Area sampling
• We try to estimate the area of the pixel covered by a rectangle of width one pixel
• Normalizing the area of a pixel to 1.0: the estimated area = the pixel intensity
20
10 11 12
21
22
X
Y
Area sampling
• Area estimation: Calcualte the number of subpixels within the rectangle. A subpixel is inside if its lower lefthand corner is inside the rectangle.
Anti-aliasing Area Boundaries
• Area boundaries are notoroius for their jaggedness
• Estimate pixel intensities at area boundaries from the fraction of the pixel inside the boundary
• Do this concurrently with scan-line algorithms
Anti-aliasing Area Boundaries
• The pixel area covered by the interior of a polygon can sometimes be calculated accurately very quickly: mxk+b-yk+m/2
y = mx + b
xk xk+1
yk
yk+1