
Why pinhole camera images are out of focus. 

MAKING THE PINHOLE
The primary influence on the technical quality of a photograph taken using a pinhole camera is obviously the hole. In order to achieve the sharpest photograph, the hole must be of the optimum size, perfectly round and should be made from the thinnest material. However, the truth is that the quality and size of the hole are not such critical parameters as one might think at first glance. Interesting pictures can be taken using almost any hole. Also, sharpness alone does not always have to be the most important requirement. Photographs from a pinhole camera are always a little less sharp and sometimes a certain amount of blur can, in itself, be an attractive means of expression.
Optimal pinhole diameter
The principle of the pinhole camera ensures that the image of a point is, in fact, a small disc. The smaller the hole, the smaller the disc and hence the sharper the image. However, this is only true up to a point. If the hole is too small, then light is diffracted and the image becomes less sharp. Hence, an optimum hole diameter exists for each focal length (distance from the hole to the lightsensitive material) which will create the sharpest picture.
Most probably, the first person to try to find a formula for calculating the optimum hole diameter was the famous mathematician and physicist Josef Petzval in the mid19th century. It was later improved by the British Nobel PrizeWinner Lord Rayleigh. The equation, on which he worked for ten years and which is valid to this day, was published in his book Nature in 1891. Several more formulas have appeared since that time, often derived from the same base.
The formula proposed by Lord Rayleigh, revised so that the result gives the diameter, not the radius, can be written as follows:
d – pinhole diameter
f – focal length
l – wavelength (usually the wavelength for yellow/green light 0.00055 mm is used)
To make the calculation of the optimum hole diameter or the optimum focal length easier, you can use the PinholeDesigner program.

