Assignment 3 Camera Simulation
Name
Date submitted: 08 May 2006
Code emailed: 08 May 2006
Compound Lens Simulator
Description of implementation approach and comments
Well, the implementaiton consisted of 4 parts:
1) Reading in the file. After learning how to use c++ streams this wasn't too bad at all. My main issue that cost me coutless hours is that the file is BACKWARDS from what I thought it was. We always trace rays from the camera, so naivly I thought that is how the file would be set up. Woe was me I output each ray as it was shot and plotted it in matlab. They all went the wrong way! They came inwards instead of going outwards.
I then created a lensSphere object that holds the center of the sphere, its radius, n, previous n, and apature size. This handles the intersection too.
2) Sampling the back lens. Not too hard.
3) Sphere interesection. This wasn't working for the longest time. I know how to use the Quadratic function properly so I did the quadratic formula myself. Thanks grade 12 math.
4) Snell's Law. I did this 3 ways. First I tried to rotate about the cross product of the ray and the normal by the correct angle. Didn't work. Then I found a paper on the vector form of snell's law. Worked. Then I found something on wikipedia, which also worked.
My images are still kinda funky. I have spent countless hours on this, in addition to the 1.5 hours that Kayvon and I spent fix them, but to no avail. If anyone has any ideas as to why there is some transparency in the middle and sides of my image please let me know!
Update Sean told me that he had the same thing with exrtotiff and that photoshop cleans these things up. Is this a bug with exrtotiff or with our images?
Final Images Rendered with 512 samples per pixel

My Implementation 
Reference 
Telephoto 

Double Gausss 

Wide Angle 

Fisheye 
Final Images Rendered with 4 samples per pixel

My Implementation 
Reference 
Telephoto 


Double Gausss 

Wide Angle 

Fisheye 
Experiment with Exposure
Image with aperture full open 
Image with half radius aperture 


Observation and Explanation
This should be stopping down by 2 F numbers. This should correspond to an image with 1/4 of the brightness, since the apature is 1/4 the area. Interestingly we only get about a 1/2 reduction in brightness. 13.57% of the rays passed through instead of the usual 27.58%. This is because the original apature didn't block many rays at all, the apature of the lenses did most of the blocking. If we stop down from the 8.55 radius I expect to get 1/4 of the rays through. And drumroll please... 4.02% of the rays go throught. Here is the pic:
Autofocus Simulation
Description of implementation approach and comments
Well, this took a really really long time to get going. My operator was not working at all, here is a graph of the SML with applied to black and white images of the reference area: .
As you can see, it is monotonically decreasing. :(.
So, after days of work, I finally normalized my images before applying the SML operator (dividing by the max value). Now, here is the SML operator for the bg image:
and for the telephoto:
I search through the range 5 to 200 and ignore all the values until it drops below a focus of 300 SML points. This is equivlent to searching the other way and stoping as you get far from the mean, but I found this way to work much better. I would have much prefered to use a binary search but the SML operator is so noisy you can't tell a good derivative.
Final Images Rendered with 512 samples per pixel

Adjusted film distance 
My Implementation 
Reference 
Double Gausss 1 
62.5 mm 


Double Gausss 2 
39.5 mm 


Telephoto 
117 mm 
