James Bigler: CS6650 Homework 1
Using this function L(x,y) = 0.5 * (1 + sin(0.01 * x*x + 0.01 *
y*y)) plotted over the domain of x:[0,255], y:[0,255] the artifacts of
aliasing is immediately noticed. The image can be antialiased by
using a filter. I used a bspline filter with orders 0 to 5 and the
Mitchel filter.
Overall, the bspline filter out performed the
Mitchell filter, as well as producing an image with fewer artifacts.
The artifacts seen in the Mitchell filter can be minimized by
increasing the number of samples per pixel, but even after 100,000
samples per pixel there was still extra ringing.
Bspline order -1 (sampled directly at xi,yi)
 |
Bspline order 0 (sampled with 1000,100,10,1 samples per pixel)
Bspline order 1 (sampled with 1000,100,10,1 samples per pixel)
Bspline order 2 (sampled with 1000,100,10,1 samples per pixel)
Bspline order 3 (sampled with 1000,100,10,1 samples per pixel)
Bspline order 4 (sampled with 1000,100,10,1 samples per pixel)
Bspline order 5 (sampled with 1000,100,10,1 samples per pixel)
Mitchell Filter (sampled with 100,000 10,000 1000 samples per pixel)
// this is sample code
// the function that evalulates L
static float L(float x, float y) {
return (0.5 * (1 + sinf(0.01*x*x + 0.01*y*y)));
}
// evaluates a random sampling with an order order bspline distribution
float BSplineSample::bspline_eval(int order) {
if (order < 0)
return 0;
else if (order == 0)
return -0.5 + drand48();
else
return bspline_eval(order - 1) - 0.5 + drand48();
}
// returns a color based on the pixel position x and y
RGB BSplineSample::render(const int x, const int y){
float val = 0;
for (int i = 0; i < iters; i++)
val += L(x + bspline_eval(order),y + bspline_eval(order));
val /= iters;
return RGB(val,val,val);
}
// the Mitchell filter function
float MitchellSample::mitchell_eval(float x) {
// Take the absolute value of x
if (x < 0) x = 0 - x;
// Now compute the value
if (x < 1)
return (7./6 * x*x*x - 2. * x*x + 8./9);
else if (x < 2)
return (-7./18 * x*x*x + 2. * x*x - 10./3 * x + 16./9);
else
return 0;
}
// computes the value of the pixel based on the Mitchell filter
RGB MitchellSample::render(const int x, const int y) {
float val = 0;
for (int i = 0; i < iters; i++) {
// get random points [-2,2]
float xi = -2 + drand48() * 4;
float yi = -2 + drand48() * 4;
val += mitchell_eval(xi) * mitchell_eval(yi) * L(x+xi, y+yi);
}
// need to multiply the average by 16 (part of Mitchell)
val = 16 * val /iters;
return RGB(val,val,val);
}