Lenses & opticsGuide

Lens selection based on resolution: feature size to MTF

Lens selection based on resolution, from a 100 µm barcode feature to pixels per module, sensor Nyquist limit, focal length and the 20% MTF contrast bar.

LumaSpec Vision12 min read Share on LinkedIn

On this page 10 sections
  1. 01How many pixels do you need across the smallest feature?
  2. 02What frequency does your feature correspond to in line pairs per millimeter?
  3. 03How many sensor pixels does your field of view need?
  4. 04What magnification and focal length follow?
  5. 05What must the lens and sensor resolve in image space?
  6. 06How do you tell whether the lens or the sensor is the limit?
  7. 07What should you check before ordering?
  8. 08When does this method give the wrong answer?
  9. 09What do you actually order for this example?
  10. 10Questions

You already know the smallest thing you have to see: a 100 µm barcode module, a 0.2 mm scratch, a 0.5 mm solder pad. Lens selection based on resolution works backward from that number — pixels across the feature, then the sensor, then magnification and focal length, then two checks in image space: the sensor's sampling limit and the lens MTF at your frequency. This guide runs one example end to end, a 2D code read from about 200 mm. It ends with the order you would actually place. Every number is derived on the page, so you can substitute your own feature size, field of view and working distance and repeat the chain.

How many pixels do you need across the smallest feature?

Plan on 3 pixels across the smallest feature for a 2D code and 2 pixels for a 1D barcode. Decoding software reaches about 1.5 pixels per module on 1D barcodes and about 2.5 on 2D codes under ideal, high-contrast conditions. That margin does not survive a factory floor.

A module is the smallest bar or space in the code, and it drives everything downstream. Commercial decoder specifications quote minima near 2.5 pixels per module for 2D codes and 1 to 1.5 for 1D. Benchmark datasets spread from 0.5 to 4 pixels per element. Print spread rounds bar edges, light falls off toward the field edge, and focus is never perfect. So design at 3 pixels per module for 2D codes, 2 for 1D, and 4 to 5 when the mark itself is low contrast. If you decode from stored frames rather than live ones, keep every pixel — barcode decoding that preserves the pixels covers what resampling does to module edges.

What frequency does your feature correspond to in line pairs per millimeter?

A 100 µm bar separated by a 100 µm gap is one line pair every 0.2 mm, which is 5 lp/mm in object space. Putting 3 pixels on that bar sets the object-space pixel size at 33 µm.

One line pair is a dark element plus the light element beside it:

frequency [lp/mm] = 1000 / (2 x feature size [µm]) object pixel [µm] = feature size [µm] / pixels per feature

For the example: 1000 / (2 x 100) = 5 lp/mm, and 100 / 3 = 33 µm per pixel. Write both numbers down now; the rest of the chain is arithmetic on them. Where the feature is round or irregular, use its narrowest dimension, because under-sampling the narrow direction is what kills the read. Seen from the image side, the same quantity is object space pixel size from magnification.

How many sensor pixels does your field of view need?

Divide the field of view by the object-space pixel size. A 35 mm field of view at 33 µm per pixel needs at least 1050 pixels on the sensor's short side. The aspect ratio, not the megapixel count, decides which sensors pass.

The 25 x 25 mm code plus placement tolerance sets a 35 mm square field of view. Most sensors are 4:3, so the short side carries it and the long side floats:

Sensor Short-side pixels Object pixel over 35 mm Pixels per 100 µm module Verdict
VGA 640 x 480 480 73 µm 1.4 Fails
1600 x 1200, 4.5 µm 1200 29 µm 3.4 Passes

VGA gives 35 / 480 = 73 µm per pixel, barely one pixel per module — undecodable. The 1600 x 1200 sensor gives 35 / 1200 = 29 µm and 3.4 pixels per module, which passes. Its active area is 1600 x 4.5 µm = 7.2 mm by 1200 x 4.5 µm = 5.4 mm.

The catalog equivalent of that class today is a 12 MP C-mount GigE camera. The LS-CMR-0053 is a 12 MP GigE area scan camera, IMX226, 1/1.7" rolling shutter, 9 fps. Twelve megapixels in 4:3 is about 4000 x 3000 pixels, so the short side clears 1050 almost three times over and leaves room to crop. A rolling shutter is fine on a stationary part; for codes moving past the camera, choose a global-shutter model in the area scan cameras finder. The same arithmetic for defects instead of codes is in camera resolution for defect detection.

Area scan cameras12 MP GigE area scan camera, IMX226, 1/1.7" rolling shutter, 9 fps (LS-CMR-0053)LS-CMR-0053
Sensor format
1/1.7"
Lens mount
C-mount
Interface
GigE
Resolution
12 MP
$560.00View partBuild a system with it

What magnification and focal length follow?

Magnification is sensor size over field of view — 5.4 mm over 35 mm is 0.154x. The focal length at a 200 mm working distance is f = WD x m / (1 + m) = 200 x 0.154 / 1.154 = 27 mm, so a 25 mm lens is the standard pick.

m = sensor width / field of view f = WD x m / (1 + m)

Lenses come in fixed focal-length steps, so round and re-solve for distance:

  • Exact fit: WD = f x (1 + m) / m = 25 x 1.154 / 0.154 = 187 mm. The field of view is exactly 35 mm at 29 µm per pixel.
  • Fixed 200 mm envelope: m = 25 / (200 - 25) = 0.143, field of view = 5.4 / 0.143 = 37.8 mm, object pixel = 4.5 / 0.143 = 31.5 µm — still 3.2 pixels per module, so it passes with 3 mm less margin.
How sensor width, working distance and field of view set the focal length Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.CameraField of view (FOV)Working distance (WD)≈ fsensor width slensm = s / FOVf = WD × m / (1 + m)
How sensor width, working distance and field of view set the focal length. Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.

Both numbers come out of the lens focal length calculator, and the wider framing is in how to choose a machine vision lens focal length.

Lens focal length, field of view and working distance
Units
Solve for
Focal length
– mm
Field of view
– mm
Working distance
– mm
Magnification
– x
Angle of view
– °
Pixel on the part
– mm

Thin-lens model: m = sensor width / field of view, f = WD × m / (1 + m). Accurate to a few percent above about 150 mm; check the lens's minimum object distance.

Find lenses with this focal length Open the full calculator

For this example the lens is any 6 MP-class C-mount lens in the 25-50 mm group of machine vision lenses. The LS-FFL-0679 is a 35 mm, 2/3", 6 MP C-mount machine vision lens. A 35 mm focal length reaches the same 0.154x at 262 mm of standoff — the pick when the station has room and you want distance from the part. The sensor diagonal is √(7.2² + 5.4²) = 9.0 mm; an 8-11 mm image circle, the 2/3" class, covers it with margin. Inside a hard 200 mm envelope, set the lens finder to 25 mm and 6-10 MP.

Machine vision lenses35 mm, 2/3", 6 MP, C-mount machine vision lens (LS-FFL-0679)LS-FFL-0679
Type
Machine vision fixed
Sensor format
2/3"
Mount
C-mount
Resolution
6-10 MP
$219.00View partBuild a system with it

What must the lens and sensor resolve in image space?

Divide the object-space frequency by the magnification to move the requirement into image space — 5 lp/mm / 0.154 is about 33 lp/mm. Then check two limits: the sensor's Nyquist frequency must sit above it, and the lens MTF must hold at least 20% contrast at it.

image frequency = object frequency / m Nyquist [lp/mm] = 1000 / (2 x pixel size [µm])

With 4.5 µm pixels, Nyquist = 1000 / 9 = 111 lp/mm, and 111 / 33 = 3.4 — the same 3.4:1 as the pixels-per-module ratio, one constraint seen from both ends. The sensor passes. On the lens side, the working floor for machine vision is 20% contrast at your frequency. A rating of 6 MP on a 2/3" frame is qualified against pixels near 3.1 µm, about 160 lp/mm, so a current 6 MP lens clears 33 lp/mm roughly five times over; one published 25 mm lens curve holds about 83% contrast at 33 lp/mm at this magnification. Reading curves at a frequency, on axis and off, is in lens contrast and resolution; the sampling half is in the Nyquist limit and camera resolution.

How do you tell whether the lens or the sensor is the limit?

Convert both to object space and take the larger number. A lens holding 20% contrast to 250 lp/mm resolves 2 µm in image space, which is 13 µm on the object at 0.154x. The 4.5 µm pixel is 29 µm on the object. The sensor, not the lens, sets the limit here.

lens limit [µm] = 1000 / (2 x frequency at 20% MTF) / m sensor limit [µm] = pixel size / m

The worse of the two numbers is what the system resolves. This example pairs a 250 lp/mm lens with 4.5 µm pixels, so the sensor caps you at 29 µm — exactly the 3-pixel design target. Balance arrives when the two match: against a 250 lp/mm lens, pixels near 2 µm put both limits at 13 µm in object space. That is where modern 20 MP, 1.1" sensors sit, and why high-resolution lenses exist as a class. The LS-FFL-0567 is a 16 mm, 1.1", 20 MP C-mount lens, F2.8-22, <0.3% distortion. Twenty megapixels across a 1.1" frame works out near 2.3 µm pixels and a sampling limit near 217 lp/mm, the matched partner for sensors of that pitch. Spend on whichever side shows the larger object-space number; improving the other buys nothing.

Machine vision lenses16 mm, 1.1", 20 MP, C-mount machine vision lens, F2.8-22, <0.3% distortion (LS-FFL-0567)LS-FFL-0567
Type
Machine vision fixed
Sensor format
1.1"
Mount
C-mount
Resolution
16-25 MP
$679.00View partBuild a system with it

What should you check before ordering?

Five checks catch nearly every wrong lens: image circle against sensor diagonal, MTF at your frequency and your f-number, shutter type against part motion, exposure against line speed, and focus confirmed on a target at the real working distance.

  • Image circle. The 9.0 mm sensor diagonal must sit inside the circle the lens draws; the 2/3" class (8-11 mm) covers it, a 1/2" class does not.
  • MTF at your setting. Curves are measured at one f-number, one wavelength band, one field point. Get the curve for the condition you will run; how far apart two settings of one lens can be is the next section.
  • Shutter and motion. A rolling shutter skews a moving code, so go global on a line, and budget exposure from blur = speed x exposure: at 31.5 µm per pixel and 100 mm/s, one pixel of blur caps exposure at 315 µs. How the f-number trades light, depth and detail is covered in working f-number and magnification.
  • Bench confirmation. Image a dot grid before the line runs: the LS-LXR-0029, from the lens accessories range, carries a 0.5 mm dot grid on a 76 x 76 mm plate. At 29 µm per object pixel each dot should span about 17 pixels; count a row and you have confirmed scale, focus and field of view in one image.
Lens accessoriesCalibration boards and depth-of-field rulers, dot diameter 0.5 mm, dot grid, 76 x 76 mm (LS-LXR-0029)LS-LXR-0029
Type
Calibration targets
$189.00View partBuild a system with it

When does this method give the wrong answer?

It fails when the curve you compared is not the curve you will run: a different f-number or wavelength band can move the 20% MTF crossing by ten times. Depth of field, motion and part tilt move features out of the plane you sized.

  • Condition drift. Two published curves for one 25 mm lens at the same working distance, but different f-number and spectral band, cross 20% contrast at 250 lp/mm in one setting and near 23 lp/mm in the other — a factor of almost eleven. A lens is a family of lenses; the curve at your setting is the contract.
  • Wavelength. Under 850 nm lighting the focus lands somewhere else; use an ir-corrected lens or refocus at the working wavelength.
  • Color sensors. A Bayer filter spends half its photosites on green, so a 20 MP color camera does not deliver 20 MP of independent samples; for codes, mono wins. The details are in color camera spatial resolution.
  • Height variation. At 0.154x, magnification changes about 0.6% per millimeter of object distance — five pixels across the 25 mm code for every millimeter the part sits high or low. Decoding tolerates that; gauging does not, and a telecentric lens is the fix.

What do you actually order for this example?

Order a 12 MP-class, C-mount camera and a 25 mm-class 6 MP lens; run it near 187 mm of standoff for a 35 mm field of view, and hold the lens to 20% MTF contrast at 33 lp/mm at your f-number and wavelength.

The decision by case:

  • Hard 200 mm envelope: a 25 mm focal length at 200 mm — 37.8 mm field of view, 31.5 µm per pixel, 3.2 pixels per module.
  • Standoff free: the 35 mm lens above at 262 mm — the same 35 mm field of view with clearance from the part.
  • Part height varies, or you gauge dimensions: an object-side telecentric lens at the same 0.154x.
  • Code on a moving line: a global-shutter camera, exposure at or under 315 µs at 100 mm/s, strobed light.

The chain generalizes: feature size to pixels per feature to short-side pixel count to magnification to focal length, then the two image-space limits. Run your own numbers in the lens step of the configurator, or send the feature size, field of view and working distance through the contact page and we will size it with you.

Questions

Can a higher-resolution camera make up for a soft lens?

No. The lens MTF caps the contrast that reaches the sensor; smaller pixels sample that image more often but cannot restore modulation that never arrived. Extra pixels do help where contrast is already adequate: sub-pixel edge fitting on a sharp edge reaches roughly a tenth of a pixel of repeatability, which improves measurement, not decoding. If the lens misses the 20% contrast bar at your frequency, the fix is the lens or the lighting, never the pixel count.

Does a megapixel rating guarantee a lens resolves my sensor?

Only when the formats match. A rating is measured on one sensor size: 6 MP on a 2/3" frame works out to about 3.1 µm pixels and a Nyquist limit near 160 lp/mm, while the same 6 MP on a 1" frame is about 4.5 µm and 111 lp/mm. Same number on the box, different demand on the glass. Compare the image circle and the lp/mm the rating implies on your format, then read the MTF curve at the frequency your feature maps to.

Where should you set the aperture for a code read at 0.15x?

Start at f/5.6. Depth of field grows in proportion to the f-number, and the resolution cost here is small: the diffraction cutoff is 1/(λ x N), which at 550 nm is 227 lp/mm at f/8, seven times the 33 lp/mm requirement, so aberrations and alignment dominate, not diffraction. At f/4, depth of field with a one-pixel blur tolerance is about ±0.9 mm (DOF ≈ 2 x N x c x (1 + m)/m²); f/8 doubles it to ±1.8 mm. Below f/2.8, corners and field curvature usually soften.

What buys back contrast if the lens barely passes the 20% bar?

Usually the light, not the glass. Cut blur first: at 100 mm/s, an exposure of 315 µs costs a full pixel of blur at 31.5 µm per pixel, while 100 µs costs about a third of a pixel; strobing buys that instantly and freezes the part. Then geometry: diffuse, even illumination removes the specular washout that erases thin bars on glossy labels, worth more contrast than a lens swap. Only if the curve still sits at the 20% floor at your frequency should you change the lens.

When is a telecentric lens the right call for code reading?

When part height varies or the code sits on a stepped surface. A fixed-focal-length lens at 0.154x changes magnification about 0.6% per millimeter of object distance, so ±2 mm of height moves a code edge roughly ten pixels. Decoders tolerate that easily; a gauge meant to hold a tenth of a millimeter does not. An object-side telecentric lens holds magnification constant through millimeters of depth and lights the field evenly; it is the pick for measuring over height and overkill for reading a label on a flat tray.