How to use depth of field to your advantageDepth of field is important for acquiring a sharp image of an object you are inspecting. With the right use of depth of field, you can ensure that the object you inspect is in focus, while the background and foreground are not in focus. That way it is easier for your vision software to recognize your object.

Depth of field is an important factor that you can use to your advantage. This article will explain what depth of field is, and how to use it.


Technically, the depth of field is the distance between the nearest and furthest object of the image that is in focus during acquisition. In the image below, the working distance is 250mm. The closest object to the lens is 190 mm away. The furthest object is 250mm away and in between is an object 210mm away from the lens. 

If your camera set up has a shallow depth of field, for example 30mm, it would be possible to get the closest, and the second object in focus, but the furthest card would be out of focus. By controlling the depth of field you could get all three items in focus, or for example specifically blur two of the three cards.


The aperture of the iris has a great influence on how large the depth of field is. If the iris is wide open, for example, F1.4 of F2.0, the depth of field is relatively small. In some cases (F1.4), the depth of field could be a just a few millimeters. Everything outside of this area is out of focus. If the iris is almost closed, for example F16, the depth of field is larger and most of the image will be sharp. Please note that when you close the aperture, the image will become darker. To compensate this, you need to increase the exposure time, gain or light.
To illustrate the effect of the aperture on the depth of field we set up a test. In the example, we focus on objects at different distances from the camera.

Example F1.4

As previously mentioned, a large aperture (low F-number) will result in a small / shallow depth of field. A small depth of field is required if you have objects in the foreground or background that you want to blur.
Pro’s F1.4
  • Very light-sensitive (short exposure time and little to no digital gain required)
  • Blur object in the foreground or background (easier for image processing software)
Con’s F1.4 
  • Small depth of field (important information might not be sharp)
The image below illustrates that the card at 250mm is sharp, the card at 210mm is already not perfectly in focus, and details might not be clear for your image processing software. The card at 190mm is even more blurry and unusable. 

Images have been compressed for web.

Example F8

As previously mentioned, a small aperture (high F-number) will result in a larger depth of field. A large depth of field is required if your object has different heights that needs to be inspected. Additionally, it is also required, if you have multiple objects that can be closer or further away from the camera. A larger depth of field will allow both objects to be in focus.
Pro’s F8
  • Large depth of field (larger area will be sharp)
Con’s F8
  • Less light-sensitive (longer exposure time or more digital gain required. Adding extra light source might be necessary)
  • Harder to blur objects in the foreground of the background
As you can see, the card at 250mm and 210mm are acceptably sharp. The card at 190mm is still blurry but not as blurry as in the F1.4 example. The lost light has been compensated with a longer exposure time and digital gain. A longer exposure time can result in motion blur for moving objects. A high volume of digital gain will result in visible grain.

Images have been compressed for web.


  1. Is the depth of field too small, but closing the aperture is not an option? Try increasing the distance between the object and the camera. In this case, the pixels per millimeter will decrease. If this becomes problematic, try a lens with a higher focal length.
  2. Closing the aperture further for a larger depth of field will result in darker images. Make up for this loss by enlarging the exposure time, adding digital gain, or adding an extra light source. 
  3. If your object is not completely sharp, try closing the aperture a bit. The higher F-number will result in a larger depth of field.
  4. If possible, try to keep the aperture below F8. If you close the aperture more, you will also loose image quality due to the optical resolving power of the lens (see image below)
In this example we have used F16. The aperture was almost completely closed. All cards are the evenly sharp, but the total image quality is not as good as you would prefer. 

Images have been compressed for web.

If you have any questions regarding this subject, get in touch with us! We answer all emails within 24hrs.
Not enough items available. Only [max] left.
Add to WishlistBrowse WishlistRemove Wishlist
Shopping cart

Your cart is empty.

Return To Shop

Add Order Note Edit Order Note
Estimate Shipping
Add A Coupon

Estimate Shipping

Add A Coupon

Coupon code will work on checkout page