11/20/2012

Camera Lens Fundamentals

What are some fundamental lens specifications that are crucial to successful machine vision applications?  Lenses on the market vary widely (in price, configuration, and performance. Review of the following five factors  is essential before purchasing the appropriate lens.
  1. Focal Length
  2. F-Number (f/#)
  3. Resolution
  4. Field of View (FOV)
  5. Depth of Field
 Although some machine vision applications could be successfully integrated by verifying lens focal length against the desired Field-of-View and Working Distance (distance from lens to object),  successful Vision System integrators must consider choice of a lens based on the intricate requirements of the application. Many applications today require accurate and reliable measurement capability, including feature resolution that demands the proper choice of a lens.
What follows are lens fundamentals and simple equations that can be used in the design of a vision system. 
Figure 1: 2D Code Reading Application
 Focal Length
Most lenses have fixed focal lengths. Typical standard focal lengths are 6mm, 8mm, 12mm, 16mm, 25mm, 35mm, and 50mm. To determine the focal length for an application, a simple formula is used.  This specification  relates the distance and size of the real-world object to be imaged to the distance (focal length) and size of the camera sensor:
Focal Length / Sensor = Working Distance / Field of View                    or
 f/H = WD/FOV, where H is the horizontal width of the imaging sensor.
This simple proportional relationship is illustrated below.
Figure 2: Similar Triangles shown can be used for determining focal length of a lens for an image projected onto a camera sensor
Camera sensors come in a variety of sizes and are  specified by the camera manufacturer. Sizes of ¼”, 1/3”, ½”, 2/3”, and 1” are typical, and are approximately 1.5 times the length of the diagonal of the sensor. Therefore, the actual sensor’s height, width, or diagonal should be used (see below for standard sizes).

Figure 3: Common camera sensor sizes
For example, a 1/3” sensor camera is located 600mm from the object to be imaged. The object has a 180mm region of interest, or field-of-view to be imaged. The Focal Length of the ideal lens would be given by (600/150)*(4.8) = 19.2mm, so a 16mm focal length lens would be a good choice. Back-calculating, a 16mm lens would provide a FOV of 180mm.

F-Number (f/#)
The f/# (or F-Number) is provided by the lens manufacturer and is typically specified at the largest diameter aperture of the lens. It is defined as the focal length divided by the lens aperture and is given for a light source located at infinity:

f/# = focal length / aperture
 
A “fast” (or low) f/# generally indicates better performance through decreased diffraction. Most lenses have f/# markings of 1, 1.4, 2, 2.8, 4, 5.6, 8, 11, 16, 22, etc. Each consecutive marking increases the f/# by a factor of . Therefore, increasing the f-number from one marking to the next on the lens corresponds to a decrease in aperture. The reduction is a multiplicative factor of 1/  and a decrease in flux density (amount of light) by half. This means that the same amount of light will reach the camera sensor if the lens is set for f/1.4 at 200 microseconds, f/2 at 400 microseconds, or f/2.8 at 800 microseconds.[i] 

The finite instance of the f/#, defined as ff/#, takes into account the magnification of the imaging system and is defined as follows:
ff/# =  (f/#)(Magnification + 1)

The lens magnification is simply the size of the camera sensor divided by the Field of View (FOV):
Magnification = W­camera / WFOV
Resolution

A lens must be chosen that is compatible with the camera sensor resolution. For high resolution cameras this often means purchasing a more expensive lens. The choice of appropriate lens is important with high pixel resolution (i.e. number of pixels on an imaging sensor) and good spatial resolution of a vision system (how close two lines or features can be apart from each other and still be resolved as separate objects). For the purposes of resolving specific features in an image accurately, factors such as contrast, image noise, and depth of focus must be considered.
Diffraction is the term used when light departs from standard geometrical optics and is a direct result of the wave nature of light. When light interacts with the imaging lens and focuses on the camera sensor, a Fraunhofer diffraction pattern results that could describe each point source of light entering the lens. A circular aperture causes what is also called the airy diffraction pattern (shown below)[ii]. It can be described as a central bright circle with outer concentric rings. The smallest point that a lens can focus light is called the airy disk and is therefore directly associated with the resolving power of a vision system.


Figure 4 - Fraunhofer Diffraction Pattern. http://www.aqualight.info/MSc/plots/jpg/p123g.gif
The airy disk diameter (ADD) can be calculated using the finite instance of the f/# that took into account the lens magnification, as follows:
ADD = (2.44)(ff/#)(λ),
 
where λ = 0.630 micrometers is a standard wavelength of light to use (red). If the ADD is greater than the size of the sensor’s pixel diameter, the resolving power of the camera will be limited by the lens. Since a “faster” lens (smaller f/#) typically increases with cost, if the ADD is significantly less than the sensor’s pixel diameter, it may be possible to use a less expensive lens and still achieve the same image quality.

As can be imagined, the sensor pixel size will also limit resolution and is defined by the Nyquist Frequency. Note that although the Nyquist Frequency provides a limit for sensor resolution, image processing algorithms generally provide sub-pixel resolution for edge detection. Sub-pixel resolution for crisp edges may be 1/10 or better. It can be measured by determining the repeatability of the measurement of interest in a real-world application. The Nyquist Frequency is given by the following equation and is typically expressed in terms of lp/mm:

Nfreq = 1/(pixel size * 2)
The unit lp/mm stands for line pairs per millimeter and is a very useful lens parameter for comparing lenses at a specified working distance. Also useful is the Modulation Transfer Function or MTF curves.  This plots the resolving power of a lens (in lp/mm) and the level of contrast (in percent) achievable. The MTF curves therefore take into account another important feature of lens resolution: contrast.

                Example: Application consists of the following imaging requirements: Lens Focal Length = 25mm, Sensor Format = 2/3”, 5MP Camera with camera pixel size of 3.5 microns, and FOV = 320mm. Edmund Optics sells the 25mm 55-326 Double-Gauss Lens for $395 and the 25mm TechSpec 63-781 lens for $995. Which lens is appropriate for this application to obtain maximum resolving power? The 63-781 specification lists f/# = 1.8 and the 55-326 lens specification lists f/# = 4. For the 63-781 lens, ff/# = (f/#)(Mag + 1) = (1.8)(Mag + 1) = (1.8)((8.8/320)+1) = 1.85; ADD = (2.44)(ff/#)(λ) = (2.44)(1.85)(0.630) = 2.84 microns. The 55-326 lens, in contrast, gives an ADD of 6.23 microns which is much larger than the pixel size of the camera sensor (3.5 microns). If the less expensive 55-326 lens was chosen, the 5MP camera would resolve almost half the detail as the 63-781 lens. The lens specification of the 63-781 lens also lists a 145 lp/mm resolution at the stated working distances. For the 3.5 micron pixel size, the Nyquist Frequency = 1/(0.0035*2) =143lp/mm which is very close to the 145 lp/mm of the lens. Again, this is approximately 1.5x better than the special resolution provided for the 55-326 lens and is a very good match for the resolution capability of the camera sensor itself.
For real-world applications, Edmund Optics provides a good article on using a star target for comparing similar lenses: http://www.edmundoptics.com/learning-and-support/technical/learning-center/application-notes/imaging/how-important-is-resolution-in-an-imaging-system/ 

Field of View (FOV)
The Field of View of a vision system is the real-world units (millimeters, for instance) of the width of the object plane being imaged. In the example above, for instance, a 320mm FOV means that the object plane at the focus of the camera is 320mm in width. For most camera systems, the FOV should be at least 10% larger than the object to be inspected. Of course, inconsistent placement of the object to be imaged may require a larger Field of View.

Within the FOV, the pixel resolution of the camera can be defined simply in terms of the number of pixels per millimeter and relates the object plane to the image plane of the camera. At a minimum, an image detail to be inspected should cover at least 2 pixels on the image sensor to be resolved. However, other limiting factors such as image noise, lighting variation, or poor contrast may realistically bring this to 5 to 10 pixels in size.
Depth of Field
The Depth of Field (DOF) is the range in which the camera lens is able to maintain the required focus for the application. It is a measure of how well the vision system maintains focus of the object when the object is moved closer or further away from the camera.

A higher f/# will result in a higher DOF. The same principle is involved when a person squints their eyes (smaller aperture or greater f/#) and therefore is able to focus over a greater range (DOF). The same is true for contrast. Conversely, a smaller f/# allows more light to reach the camera sensor. For this reason, DOF, light intensity, and contrast must be balanced with the resolution (f/#) during lens selection.


[i] Hecht, Eugene. Optics. 4th Ed. Pgs 174-175. Copyright © 2002 by Addison Wesley Longman, Inc. ISBN 0-8053-8566-5.
[ii] AquaLight. <http://www.aqualight.info/MSc/plots/jpg/p123g.gif>

1 comment:

  1. I'm impressed with the amount of content in this article. You consolidated a lot of worthwhile information to create a down to earth read on camera lens fundamentals. This is a great resource!

    ReplyDelete