Assignment:
Create a web page that has nine
images that you create by a program.
The intensity (between 0 and 1) of the image is:
double f(double x, double y, double kx, double ky, int nx, int ny) {
return 0.25*(x/nx)*(1+cos( kx* x*x))*(y/ny)*(1+cos(ky*y*y));
}
where the image has nx by ny pixels and
on the coordinate system where (x,y) in a member of the set [0,nx] X [0,ny],
and (nx,ny) = (512,384) and kx=0.004 and ky=0.006.
The coordinate system is that pixel 0,0 is the lower lefthand
corner and pixel i,j covers area [i,i+1] \times [j,j+1]
For each of regular, random, and jittered samples, create an image
with 4, 16, and 64 samples per pixel. For the random and jittered samples,
use a different sample set for each pixel.
One way to think of this assignment is that you are looking through a
window screen (like the one to keep flies out) and you see different
intensities through the holes. As x and y get bigger you see lots
of high frequencies even through one screen hole. Your mission is to
make an image where each pixel is the average intensity seen through
each screen hole. You do this for one pixel
by sampling several points and averaging the function value.
For example, with four samples, the estimate of the intensity of
pixel (7,4) might be:
f(7+r(),4+r(),...) +
f(7+r(),4+r(),...) +
f(7+r(),4+r(),...) +
f(7+r(),4+r(),...)
where r() is a function like drand48() that returns random numbers in (0,1)
Gamma correction
While you are computing a greyscale intensity between zero and one, you
may need to output a 24-bit RGB. For most image files you would
write 0 0 0 for black and 255 255 255 for white. Because monitors
are non-linear, you should gamma correct the intensity before
writing it to a file. For monitors with gamma 2, each of the R, G, and
B channels would be int(255.99*sqrt(I)) where I is the intesity.
You use 255.99 to handle the case where I is exactly 1.0.
My Answer:
| Regular image with 4 samples. |
Regular image with 16 samples. |
Regular image with 64 samples. |
 |
 |
 |
|
| Random image with 4 samples. |
Random image with 16 samples. |
Random image with 64 samples. |
 |
 |
 |
|
| Jittered image with 4 samples. |
Jittered image with 16 samples. |
Jittered image with 64 samples. |
 |
 |
 |