Pinholes and Lenses
One problem with pinhole cameras, is that the images that they create are very, very dim and that's one of the reasons that they are so hard to capture and the reason that the images are dim, is if we look at all the light rays that emerge from a particular point, in this example, only one of those light rays goes through and forms the image, the rest of the light rays hit the opaque plane and are absorbed or reflected off to somewhere else.
So if we want to make our image brighter we need to be able to utilize more of the light rays that are leaving the object and the way we do that, is to use a lens.
A lens is a very simple technique for gathering more of the light rays that leave a particular point in the world. Again we have our graphical example and we can see the light rays leaving one particular point, they've all passed through the lens and strike the image plane. So here we've captured many, many more light rays, so the image that we form will be brighter.
We can describe this a bit more formally. We consider the distance away from the lens plane which we will call the distance F and the diameter of the lens which is the distance Phi and we can create a number, which is generally referred to as the F-number of the lens, which is the ratio of F to Phi. The F-number of the lens is typically inscribed on the front of the lens; in this case it's a F1.4 lens so that means capital F equals 1.4. The smaller the F-number the greater is the light gathering power of the lens, the brighter image that it will create. Let's simplify things and see how lenses work.
We have a simple object in the world and we have a lens. And a lens is described by a focal length and in this case we have what we call a thin lens model. This is probably familiar to you from high school physics. The real lenses that you have in your camera are not simple lenses like this, but they can be approximated by a single lens.
The lens is described by two focal points, each a distance F away from the centre plane of the lens. To see where the image of the object falls, we perform this very simple geometry and the small arrow shows where the image will be formed. It's the intersection of the two yellow lines. This image formation process is described quite simply mathematically, the distance of the object which we call "Zo" the distance at which the image is formed "Zi" is related by this equation here, so Zi is the distance away from the centre of the lens, where a sharp image will be formed and that's what we call the "Image Plane." That's where the image is formed and that's where we put the sensor. Now the sensor might have been a piece of film in the old days, today it's much more likely that we place a semiconductor imaging chip; a large array of light sensitive elements and the output of this array is recorded digitally and placed into the flash memory in the phone or the camera.
Now let's look at what happens if I move the object a little bit closer to the lens. The value of Zo has been reduced and we do the geometric construction, we see now that the image is formed in a different place; Xi has got a different value, as given by the equation down the bottom. What this means is that if I had the image plane in the original location, I would have a fuzzy image there; that image would be out of focus.
In order to create a focussed image, I need to move the image plane over to here and if I place the image plane there, then I will have a sharp image of my object. And so this is what happens when I adjust the focus of an old fashioned type camera. As I rotate the lens in order to focus it, there's a screw thread there which is actually moving the lens away from the plane of the sensor or the film. So in order to focus a camera, what I need to do is to change the distance between the lens and the plane where the image is formed and captured.
Here's an animation that shows this. As the object moves towards the lens, we can see, just using the simple geometric construction, that the location of the image is moving further and further away from the lens, so in order to bring it into focus, I need to move the image plane away from the lens.
Interestingly a pinhole camera does not require focussing. Irrespective of the distance of the object, the image that it forms is always sharp, but the disadvantage of the pinhole lens as I mentioned earlier, is that the images are very, very faint. So it doesn't need focussing but it doesn't produce bright images.
The pinhole camera simplifies the geometry but in practice it results in very dark images. Cameras, as well as our eyes, use a lens to form a brighter image but there are consequences.
High school mathematics
This content assumes an understanding of high school-level mathematics, e.g. trigonometry, algebra, calculus, physics (optics) and some knowledge/experience of programming (any language).