Thursday, October 13, 2011

F-stops, resolution and depth-of-field

One of the most baffling aspects of machine vision technology is finding the “ideal” lens settings. Unless you’re serious about photography, (and I am not,) terms like “f#” and “diffraction limited” might as well be in Mandarin. This is why I lap up any and every article I can find on optics, and is the reason I read “Into the Depths,” (Vision Systems Design, September 2011,) several times.

Written by the very knowledgeable Greg Hollows of Edmund Optics, this article attempts to clarify the relationship between the size of the aperture, (indicated by f#,) the depth-of-field, and the resolution of an imaging system. Unfortunately though, I still found it too complicated and had to resort to Wikipedia.

And what did Wikipedia tell me? Well as part of MV4U’s mission to simplify machine vision for users, I shall summarize and then direct you to some useful sources.

f# - this tells you how open or closed the lens aperture is. Much confusion comes from the fact that a small f# means the aperture is wide open while a big number means it’s very small. Thus at f# of 1.2 the aperture is wide open and much light can pass through, while at f# of 16 the aperture has been closed down to a pinhole and hardly any light can get through.

When light passes through a pinhole it gets bent, or diffracted, a lot. This doesn’t happen so much with a bigger diameter hole. Diffraction is a bad thing because it reduces the resolution of the imaging system. In simple terms, the more diffraction that takes place, the more blurry the image. So to get a good image, open the aperture wide, (or as a photographer would say, use a small f#.)

But here comes a problem: when the aperture is open wide the depth-of-field is very shallow. In other words, the image is only in focus over a very small change in working distance – maybe just a few millimeters. Close the aperture down (increasing the f#,) and the range over which the object stays in focus increases.

So how does the eager vision engineer balance these tradeoffs? Well from Wikipedia I ended up at “Lens Diffraction & Photography” on the website. (Be sure to read both pages.) This has two excellent diffraction limit calculators; one finds the circle of confusion, the other estimates the f# at which resolution will start to be compromised. I found that playing with these in conjunction with the Greg Hollows’ article help make his explanations clear.

The other useful calculator I found was for estimating depth-of-field. Again, this is useful for trying things out and seeing what effect they have.

Lenses are mysterious things for most of us engineers. Hopefully these links and my explanation will help bring it all into focus. (Loud groans please!)

No comments: