In Handbook for Scientific Photography (1977), Alfred A. Blaker wrote:
As the substage diaphragm is closed, the depth of field increases (as when you close the diaphragm of your camera lens)...However, diffraction of light by the edge of the diaphragm increasingly impairs the image resolution until the image becomes "rotten."He was explaining how to take pictures thru a microscope using a camera back and the substage diaphragm he was referring to is the one under the stage of a microscope. One encounters a similar diffraction effect when using a camera with a lens to take closeup* pictures. Blaker explained this in another book, Field Photography (1976):
...at significant magnifications the choice of f-number is...nearly always a matter for compromise between depth of field needs and the resolution of fine detail in the image. At very small apertures, diffraction of light at the diaphragm edge reduces resolution.The bottom line is that the smallest aperture will give you the greatest depth of field, but not the best resolution†.
Here are some tests I did with my Olympus 35 mm Zuiko lens on Olympus E-500. In this case, the object was a flat wood surface and so the depth of field was not an issue. Notice the decrease in sharpness as I increased the f-stop (decreased the aperture diameter).
Click on the image to view a bigger version. These are unretouched images. Some image quality was lost because I had to compress the composite picture before I could post it here.
The decrease in sharpness going from f5.6 to f11 is almost not noticeable. Even f14 would be acceptable for some purposes. But ordinarily, I avoid the apertures above f14.
Here is another example; shots of a flower bud of trumpet vine at f5.6 and f22, again with the 35 mm lens. There is a definite loss of resolution at f22.
But now let's compare the overall images.
At f5.6 with diffused sunnlight:
And at f22 with flash light:
The one at f22 has a much wider depth of field and the overall loss of resolution due to diffraction is not noticeable at this magnification. Therefore, we follow Blaker's advice and compromise and chose between depth of field and resolution. If we want a wide depth of field despite the loss of overall sharpness, we decrease the aperture; if we want a sharp focal point amidst blurry surroundings, we increase the aperture. How you take a picture depends on what you want the picture to look like and what you will do with it. In many cases, there is no right or wrong photograph as long as the image is not too rotten.
*Blaker's definitions of closeup photography as photography at image magnifications of actual size or less and photomacrography as photography at image magnifications greater than actual size are arbitrary and pointless.
†Don't confuse this with the pixel resolution of a digital camera.