The Pinhole Camera as a Pair of Similar Triangles
See why a pinhole image is upside down, how big it is, what the hole size changes, and how to work out heights from it.
Key takeaways
- Light travels in straight lines, so rays crossing at a pinhole create two similar triangles on opposite sides of the hole.
- Image height divided by object height equals screen distance divided by object distance.
- The image is turned through a half turn: top goes to bottom and left goes to right.
- A smaller hole sharpens the picture only up to a point, after which diffraction and dimness take over.
In a pinhole camera, light from each point of a scene passes through one tiny hole and lands on a screen behind it. The object and the hole form one triangle, and the hole and the image form another. The two are similar, so the image height equals the object height multiplied by the screen distance and divided by the object distance.
The same two triangles explain why the picture is upside down, why moving the screen back enlarges it, and why a distant tree and a nearby shrub can come out the same size.
Two triangles meeting at a point
Set the hole at point O. In front of it stands a vertical object of height h at a distance u, with its base level with the hole. Behind it, a flat screen stands parallel to the object at a distance v.
A ray from the top of the object runs straight through O and strikes the screen below the level of the hole. A ray from the base runs horizontally through O and strikes the screen level with it. The distance between those two landing spots is the image height h′.
Both triangles have a right angle, one at the object's base and one on the screen. Their angles at O are vertical angles, formed by two crossing lines, so they are equal. By angle-angle similarity the triangles are similar.
h′ / h = v / u corresponding sides
h′ = h × v / u
magnification = v / u This is the bowtie arrangement, one of the two pictures described in nested and bowtie triangles. The base of the object does not have to be level with the hole. Split a taller object into the part above and the part below, and each part scales by the same v / u.
Why the picture is upside down
Rays cross at the hole. Anything above it sends light to the lower part of the screen, and anything below it sends light to the upper part. The same crossing happens sideways, so left and right trade places too.
Taken together, the image is the scene rotated by half a turn about the line through the hole, then shrunk or enlarged. In the language of transformations, it is an enlargement from a center with a negative scale factor, −v / u, for the flat object plane. Enlargement from a center treats negative factors in general.
If you stand behind a translucent screen and view the picture from the side facing away from the hole, you can turn your head or the box to set it upright. The mathematics does not change.
Worked examples with real sizes
Say a tree 8 meters tall stands 20 meters from a pinhole, and the screen sits 10 centimeters behind the hole.
h = 8 m, u = 20 m, v = 0.1 m
h′ = 8 × 0.1 / 20 = 0.04 m = 4 cm Now run it backward. A tower of unknown height stands 150 meters away, and its image on the same screen measures 2.4 centimeters.
h = h′ × u / v = 0.024 × 150 / 0.1 = 36 m You can also find a distance. A person assumed to be 1.7 meters tall makes an image 1.7 centimeters high, so u = h × v / h′ = 1.7 × 0.1 / 0.017 = 10 meters.
One measurement alone cannot give both size and distance. An 8 meter tree at 20 meters and a 4 meter tree at 10 meters produce identical 4 centimeter images. Every object that fits exactly between the same two rays looks the same to the camera.
What the screen distance and screen size control
Pull the screen farther from the hole and v grows, so everything in the image grows in proportion. A fixed screen then catches a smaller part of the scene, which looks like zooming in.
The width of scene that fits comes from the same similarity. A screen of width w at distance v captures a width W = w × u / v at distance u. With a 12 centimeter screen, v = 10 centimeters and a wall 20 meters away, W = 0.12 × 20 / 0.1 = 24 meters.
The image also dims as the screen moves back. The same amount of light is spread over an area that grows with v², following the rule for areas of similar figures. Doubling v doubles the image height and width, and cuts brightness to about a quarter.
How big should the hole be?
A real hole has width, so a single point of the scene lights a small disk on the screen. Similar triangles give its size. Take a point source at distance u and a hole of diameter a. Rays from the point through the two edges of the hole keep spreading until they reach the screen, a total distance u + v from the source.
spot diameter / a = (u + v) / u
spot = a × (1 + v / u) For distant scenes v / u is tiny, and the spot is essentially the size of the hole. So geometry alone says a smaller hole gives a sharper image.
Geometry alone is not the whole story. Light is a wave, and it spreads after passing through a very small opening, an effect called diffraction. Below a certain size, shrinking the hole makes the picture blurrier. The best diameter grows roughly with the square root of the screen distance times the wavelength of light, with a numerical factor that depends on how sharpness is judged. For a screen 10 centimeters back, it comes out at a few tenths of a millimeter.
Building one and using it safely
A shoebox, a square of kitchen foil, a pin and a sheet of tracing paper are enough. Cut an opening in one end of the box, tape foil over it and prick a clean round hole. Mount the tracing paper inside, parallel to the foil, and shade your view with a cloth. Bright outdoor scenes show best.
Measure v from the foil to the paper. Then photograph or trace the image of a window frame and check the formula against a tape measurement of the real frame. Take care with the pin and the cut edges.
A pinhole can also project the sun onto paper, which is a common way to watch a partial solar eclipse. Stand with your back to the sun and look only at the projected spot. Never look at the sun through the hole, and do not use a lens or binoculars without proper equipment and guidance. The solar disk's image has a diameter of about 1/108 of the projection distance, so a distance of 1 meter gives a disk a little over 9 millimeters across. The same ratio drives the coin and moon experiment.
Why exposures are so long
Photographers describe an opening by the ratio of its distance from the image to its width, called the f-number. For a hole 0.4 millimeters wide at 100 millimeters, the ratio is 100 / 0.4 = 250. Everyday camera lenses open to ratios in the single digits.
Brightness on the screen depends on the area of the opening divided by the square of its distance, so it varies as one over the f-number squared. Compared with a lens set at 8, a pinhole at 250 gives (250 / 8)², or nearly a thousand times less light. An exposure that takes a hundredth of a second with the lens needs roughly ten seconds through the hole, and photographic paper or film may need longer still.
The compensation is an unusual property. A pinhole has nothing to focus. Near flowers and far hills are about equally sharp, or equally soft, because the spot size barely depends on distance once the object is many times farther away than the screen. A very close object does blur more: when u equals v, the spot is twice the width of the hole.
Mistakes that spoil the proportion
- Measuring to the box front instead of the hole. Both u and v start at the hole.
- A tilted screen. If the screen is not parallel to the object, one end of the image is magnified more than the other.
- Slant distances. For a flat object facing the screen, u is the perpendicular distance from the hole to the object's plane, not the longer distance to its top.
- Mixed units. Heights h and h′ may use different units only if you convert before dividing.
From a box to a mathematical camera
Put coordinates on the setup, with the hole at the origin and z measuring distance straight ahead. A point at position (x, y, z), with z > 0, lands on a screen at distance v at the position (−vx/z, −vy/z). The minus signs record the half turn. Drawing programs often place the screen in front of the hole instead, which removes the signs and gives (vx/z, vy/z).
Dividing by z is what makes distant things small. It sends straight lines to straight lines but lets parallel lines that run away from you meet at a vanishing point. It does not preserve length ratios along a receding line, so the picture as a whole is not similar to the scene. Similarity holds exactly only for flat shapes parallel to the screen.
This model is the starting point of perspective projection in computer graphics and of the rules painters use for one, two and three point perspective. Lens cameras add focusing and distortion, but the pinhole remains the reference that engineers correct their lenses toward.