Depth of Field and Depth of Focus
This is Section 4.3 of the Imaging Resource Guide
Due to similarities in name and nature, depth of field and depth of focus are commonly confused concepts. To simplify the definitions for our purposes, depth of field concerns the image quality of a stationary lens as an object is repositioned, whereas depth of focus concerns a stationary object and a sensor’s ability to maintain focus for different sensor positions, including tilt.
Depth of Field
The Depth of Field (DOF) of a lens is its ability to maintain a desired amount of image quality (spatial frequency at a specified contrast), without refocusing, if the object is positioned closer to and farther from best focus. DOF also applies to objects with complex geometries or features of different heights. As an object is placed closer or farther than the set focus distance of a lens, the object blurs and both resolution and contrast suffer. Because of this, DOF only makes sense if it is defined with an associated resolution and contrast. A number of targets can be used to directly measure and benchmark an imaging systems DOF; these targets are detailed in our Choosing the Correct Test Target application note.
DOF Requires a Resolution
“Does this lens have good depth of field?” Although a common question, it is difficult to quantify without using a specific object detail size or image space frequency. The smaller the detail, the higher the spatial frequency that needs to be resolved, and the smaller the DOF the lens can produce. A DOF curve can be used to see how a lens actually performs over a given depth at a specific detail’s size (Lens Performance Curves). These graphs not only take into account the theoretical limitations associated with the f/# setting, but also the aberrational effects of the lens design itself.
In Figure 1, the contrast levels (y-axis) that can be seen over a working distance range (x-axis) at a fixed frequency of 20 lp/mm (image detail) are shown. Note the difference in DOF between Figure 1a, which is set at f/2.8, and Figure 1b, which is set at f/4. Something else to note is that there is more usable DOF beyond the best focus than between the best focus and the lens, due to magnification decreasing. The graphs themselves contain different color lines denoting different positions where the image will fall on the sensor.
Figure 1: Depth of Field Curves for a Lens at f/2.8 (a) and f/4 (b)
Figure 2 features the same lens as Figure 1a but at a different working distance. Note an increase in DOF occurs at longer working distances. Eventually, as the lens focuses towards infinitely far away objects, the hyperfocal condition occurs. This condition is reached at the distance in which everything appears in equal focus.
Figure 2: Depth of Field Curves for a Lens at f/2.8 at 200mm WD (a) and at 500mm WD (b). Note (b) has a much larger scale
How f/# Affects Depth of Field, Conceptual
Changing the f/# of a lens will change the DOF, as shown in Figure 3. For each configuration shown in Figure 3 there are two bundles of rays. The bundle represented by dotted black lines shows how information spreads as it moves from the object toward the lens system. As an object moves away from the best focus position (where the dotted lines cross), object details move into a wider area of the cone. The wider the spread of the cone, the more the information from that distance from the lens is blurred into all of the other information around it. The f/# of the lens controls how fast the cone expands and, thus, how much information or detail is actually blurred together at a given distance.
Figure 3: Geometric Representation of DOF for High and Low f/# Lenses
There is also a red cone in the figure, which is an angular representation of the resolution of the system. Where the lines of the two cones intersect defines the total range of the depth of field. The lower the f/#, the faster the black dotted lines expand, and the lower the depth of field.
As details get smaller, the bundles in Figure 3a and 3b move closer together, accelerating the effect. Eventually, increasing the f/# too much causes smaller details to blur due to the diffraction limit of the lens being reached, since the limiting resolution of the lens is inversely proportional to the f/#. This limitation means that while increasing the f/# will always increase the depth of field, the feature size that is resolvable (even at best focus) gets larger. For more information on the diffraction limit and its relationship to f/#, see Diffraction Limit. Utilizing short wavelengths does allow for forgiveness in this area, and in many ways some of this lost resolution can be salvaged. Learn more about changing wavelength can affect system performance in Wavelength Effects on Performance.
In general, when lenses are focused at short working distances, the large cone angles cause the cones to diverge very quickly on either side of best focus, leading to limited depth of field. For objects that are in focus at longer working distances, the rate of transition of the bundles decreases and DOF will increase.
Example: f/# Effects at the Object Level, a Close Up View
Figure 4 illustrates the ray bundle at the center of an object under inspection at f/2.8 (a) and f/8 (b). The vertical lines represent 2mm increments of movement away from best focus and closer to the lens. On each vertical line, there is a square that represents a single pixel of detail. Figure 4a demonstrates that the desired amount of detail quickly becomes a limited part of each bundle as the width of the bundle exceeds the feature size. In Figure 4b, the bundle expands far more slowly and the detail is larger than the bundle diameter for all distances shown, allowing it to be the dominant signal contributor and thus more distinguishable.
Figure 4: An Illustration of the Ray Bundle at the Center of an Object under Inspection at f/2.8 (a) and f/8 (b)
Figure 5 shows the same type of illustration as Figure 4, but has cones representing multiple points in the field of view, essentially on and off information representing line pairs. The overlap in the bundles in Figure 5a shows how the information runs together more quickly than that of Figure 5b. This is an example of how information from two different object details would blur together due to a lower f/#. In Figure 5b, this does not occur due to the higher f/# of the lens.
Figure 5: An Illustration of Ray Bundles across a Portion of the Center of the Field of View at f/2.8 (a) and f/8 (b)
Depth of Focus
Depth of focus is the image-space complement of depth of field and is related to how the quality of focus changes on the sensor side of the lens as the sensor is moved while the object remains in the same position. Depth of focus dictates how much tip and tilt can be tolerated between the image plane of the lens and the sensor plane itself. The lower the f/#, the more the depth of focus is reduced and the more impact tilt has on achieving best focus across the sensor.
It needs to be understood that without active adjustment there will always be some degree of variation in the orthogonality between the sensor and the lens that is used; Figure 6 shows how this issue arises. It is generally assumed that problems involving depth of focus only occur with large sensors, however, this issue is actually independent of sensor size. As the derivation in Figure 6 shows, depth of focus is heavily dependent on the number of pixels and has little to do with array or pixel size. As sensors increase in pixel count, this issue is only amplified. Particularly in many line scan applications, the large arrays and low f/#s emphasize the need for careful alignment between the object, lens, and sensor.
Figure 6: How Sensor Tilt with respect to the Optical Axis affects Depth of Focus
Effects of Sensor Tilt
Figure 7 shows a 35mm lens using 470nm illumination. Figure 7a is set to f/2.8 and Figure 7b is set to f/5.6. Both graphs are go out to 150 lp/mm, which is roughly the Nyquist limit of a sensor using 3.45μm pixels. It is easy to see that the performance of Figure 7a is far better than Figure 7b, using this lens at a setting of f/2.8 would provide the highest level of imaging quality in a given object plane. However, as discussed in the previous section, tilt in relation to the sensor will negatively impact the actual image quality that the system produces: the higher the number of pixels, the more profound the effects.
Figure 7: MTF Performance of a 35mm lens at f/2.8 (a) and f/5.6 (b) Note that in each case, the diff raction limited resolution is nearly obtained
In Figure 8, depth of focus for f/2.8 and f/5.6 of the 35mm lens featured in Figure 7 are analyzed. In both figures, the far right vertical line represents best focus for the entire image. Each semi-vertical line to the left of best focus represents a position 12.5μm closer to the back of the lens. These simulate the positions of the pixels assuming a tip/tilt of 12.5μm and 25μm respectively from the center to the corner of the sensor. The blue ray bundle is for the center of the image and the yellow and red ray bundles are for the corner of the image. The yellow and red bundles represent one line pair cycle on the sensor assuming 3.45μm pixels. Notice in Figure 8a, f/2.8, that there is already bleed-over between the yellow and red ray bundles at the shift to the 12.5μm tilt position. Moving out to 25μm, the red bundle now covers two full pixels and about half the yellow bundle as well, causing significant blurring. In Figure 8b, f/5.6, we see that the yellow and red ray bundles stay within one pixel over the full 25μm tilt range. Note that the blue pixel’s position does not change, as the tip/tilt is centered on this pixel.
Figure 8: Ray Bundles in Image Space of the same 35mm Focal Length Lens at f/2.8 (a) and f/5.6 (b). The blue ray bundle is in the center of the image; the red and yellow bundles are at the corner of the image
Figure 9 illustrates the change in MTF performance in the corner of the image for this 35mm lens assuming 25μm of tilt as seen in Figure 8. Figure 9a shows the new performance of the lens at f/2.8, note the significant reduction in performance from Figure 7a. Figure 9b shows the performance shift at f/5.6 which minor in relation to 7b. Most importantly this lens at f/5.6 will now significantly outperform the f/2.8 setting. The drawback to running systems at f/5.6 is three times less light; this could be problematic in high speed and line scan applications. Finally, assuming that the sensor is tilted about the center of the sensor, reduced performance will occur at both the top and bottom of the sensor (and their corresponding points in the field of view) due to the tilt, since the ray bundles expand after best focus. No two camera and lens combinations are exactly the same. When building multiple systems this issue can present itself at varying degrees of magnitude.
Figure 9: MTF Performance of a 35mm Lens at f/2.8 (a) and f/5.6(b), and with 25μm of Z-Axis Shift caused by Image Plane Tilt
In order to overcome these issues, cameras and lenses with higher tolerance control should be utilized. Additionally, for sensors, some lenses have tip/tilt control mechanisms to actively overcome this effect. It is also important to note that some line scan sensors can have swale, which means that they are not completely flat; this cannot be mitigated or removed via tip/tilt control.