Mathematics of depth of field
Mathematics of pinhole cameras
- In the last lesson, we explored the geometric behavior of cameras. We saw how light bounces off objects, passes through a small hole or aperture, and hits an image plane. One of the important concepts we covered was depth of field, which is a region where objects appear in focus. Outside that region, objects appear blurry. When a point at an image is out of focus, it grows into a blurry circle known as the circle of confusion. In this lesson, we'll develop the algebraic equations which tell us exactly where things come into focus, and how big the circle of confusion will be if something isn't in focus. And these equations will allow us to create virtual cameras to create stunning images, such as this shot. To begin, let's return to our pinhole camera. As usual, when bridging the gap between geometry and algebra, we'll need to introduce a coordinate system. It's convenient to choose our coordinate system so that the pinhole is at the origin, right here. And let's imagine that our scene is off to the right. Suppose the image plane inside our camera is at some distance to the left of the pinhole. Let's call this distance i. Now consider a point on some object in our scene. Call this point x zero, y zero. When light in the environment hits this point, some of it will bounce toward the camera, through the pinhole and hit the image plane. Let's call the place it hits the image plane x one, y one. So our first question is what is x one and y one? One way to solve this is to use the slope intercept form of a line. The slope of the ray is y zero over x zero, and the y-intercept is zero because we said this ray passes through the origin. That is, the equation of the ray is just y equals y zero over x zero, times x, plus zero. Or, simply, y equals y zero over x zero, times x. Now the point we're looking for, x one, y one, is also on this ray, so it must satisfy that line equation. Meaning y one equals y zero over x zero, times x one. And notice the diagram tells us that x one is negative and a distance i away from the origin. That is, we know x one equals minus i. Finally, to get y one, we just substitute to give us y one equals minus y zero over x zero, times i. Notice that the point was originally positive but the corresponding point on the plane is negative. And that's the image flip. Okay, let's pause here to give you some experience with this before we add a lens to our camera.