Cameras & sensorsGuide

Camera resolution for defect detection: size it by the pixel rule

The 3-4 pixel rule turns defect size and field of view into the camera resolution you need for defect detection, with a worked example from 2.5 to 25 MP.

LumaSpec Vision10 min read Share on LinkedIn

On this page 9 sections
  1. 01How many pixels do you need across a defect?
  2. 02How do you calculate the camera resolution from defect size and field of view?
  3. 03Which camera resolution does each field of view need?
  4. 04What changes when the same crack sits on a 600 mm part?
  5. 05Does the lens have to keep up with the sensor?
  6. 06Can lighting make up for fewer pixels?
  7. 07When is the high-resolution camera the wrong answer?
  8. 08What do you check before ordering the camera?
  9. 09Questions

A 0.5 mm crack on a machined fitting is invisible at the wrong resolution and obvious at the right one. The difference is arithmetic, not luck. This guide gives you the rule inspectors use to size an area scan camera for small-defect detection: at least 3 pixels across the smallest flaw, 4 when contrast is weak. You will turn defect size and field of view into a pixel count, see which sensor class fits fields from 100 mm to 600 mm, and decide between one high-resolution camera and several smaller ones. The same calculation works whether the check runs on a PC with an area scan camera or at the station on a smart camera. Work the numbers first; the shopping follows from them.

How many pixels do you need across a defect?

Plan on at least 3 pixels across the smallest defect you must catch, and use 4 when the defect is low-contrast or sits on a textured surface. That margin is what separates a detection that holds from one that flickers with focus drift.

A one-pixel defect is indistinguishable from sensor noise. A two-pixel defect shows no shape. Three is where a blob becomes a blob for segmentation and match tools. The fourth pixel buys stability: focus drift, vibration and soft edges each consume roughly half a pixel, and at three the defect falls below the floor when that happens. Flagging is not measuring — if you must size the defect against a tolerance, that is a gauging job wanting about 8-10 pixels and geometry-holding optics, the territory of when you need a telecentric lens for gauging.

Everything below sizes area scan cameras framing a fixed field. For the sensor-side question of how many pixels a camera should carry at all, see High resolution machine vision cameras: how many pixels?.

How do you calculate the camera resolution from defect size and field of view?

Divide the field of view by the defect size and multiply by the pixels per defect: a 0.5 mm crack in a 100 mm field needs 100 × 4 / 0.5 = 800 pixels across, which any 2 MP-class camera clears with room to spare.

R ≥ N × FOV / d p = FOV / R n = d / p

R is the minimum sensor pixel count across, N the pixels you demand per defect (3-4), FOV the framed field and d the smallest defect. p is object-space pixel size, the millimeters each pixel covers, and n is what the defect lands on. The setup, not the sensor alone, sets p: the same 12 MP, 4000-pixel sensor gives 0.05 mm per pixel at a 200 mm field and 0.15 mm at 600 mm.

If the field is what you are solving for, the working distance and field of view formula gets FOV from sensor size and working distance first. The object-space pixel size calculation converts results into mm per pixel.

Worked example. N = 4, d = 0.5 mm, FOV = 100 mm. R = 4 × 100 / 0.5 = 800 pixels. A 2.5 MP sensor with the common 4:3 aspect works out to sqrt(2,500,000 × 4/3) ≈ 1830 pixels across, so p = 100 / 1830 ≈ 0.055 mm and the crack spans 0.5 / 0.055 ≈ 9 pixels. Margin over the 800-pixel floor is 1830 / 800 ≈ 2.3×, enough to absorb the half-pixel that focus drift and wobble take. Try your own numbers in the calculator:

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

That is the 100 mm case solved. The 2.5 MP MV-CU020-90GC with a global shutter and C-mount sits comfortably above this floor.

Area scan camerasHikrobot MV-CU020-90GC 2.5 MP Area Scan Camera, GigE, GMAX4002, ColorMV-CU020-90GC
Sensor format
1/1.7"
Lens mount
C-mount
Interface
GigE
Resolution
Up to 3 MP
$309.00View partBuild a system with it

Which camera resolution does each field of view need?

For a 0.5 mm defect under the 4-pixel rule the field of view decides everything: 100 mm needs 800 pixels across, 300 mm needs 2400, 500 mm needs 4000 and 600 mm needs 4800. The sensor class climbs from 2 MP to 25 MP as the part grows.

Field of view Pixels needed across Sensor class that fits
100 mm 800 2 MP and up
300 mm 2400 5-6 MP
400 mm 3200 12 MP with margin
500 mm 4000 12 MP at the limit
600 mm 4800 25 MP, or two 5-6 MP cameras

The counts scale linearly: halve the defect size and every pixel count doubles. Frame with margin for part wander — add 5-10% to the field and the pixel count grows by the same share, so a 600 mm part framed at 660 mm needs 660 × 4 / 0.5 = 5280 pixels across. Fields from 300 to 500 mm sit in the 12 MP class under the 4-pixel rule. The LS-CMR-0166 delivers 12 MP as 4000 × 3000 pixels at 30 fps over USB3.

Area scan cameras12 MP USB3 area scan camera, IMX226, 1/1.7" rolling shutter, 30 fps, 4000 × 3000 resolution (LS-CMR-0166)LS-CMR-0166
Sensor format
1/1.7"
Interface
USB3
Resolution
12 MP
Shutter
Rolling
$560.00View partBuild a system with it

What changes when the same crack sits on a 600 mm part?

At 600 mm the rule demands 4800 pixels across, more than any 12 MP sensor delivers. Commit to one of two layouts: two cameras each covering a 300 mm slice at 2400 pixels, or one 25 MP camera carrying the whole field.

Splitting the field relaxes each camera's arithmetic. Two cameras covering 300 mm each need 2400 pixels across; the 5 MP class, about 2580 pixels, clears that with roughly a 7% margin, which is thin, and the 6 MP class clears comfortably. Frame each slice at 330 mm for wander margin and 6 MP still holds at roughly 2640 pixels needed against about 3072 available. Filter the camera finder to 6 MP mono GigE models with a C-mount and pick one per slice.

One frame for the whole field is the other layout. The MV-CH250-25TC-F-NF is a 25 MP 10GigE camera with a global shutter and an F-mount for the larger optics a wide field implies. At the roughly 5120 pixels across that 25 MP machine-vision sensors offer, p = 600 / 5120 ≈ 0.117 mm and the crack spans 0.5 / 0.117 ≈ 4.3 pixels, above the 4-pixel floor.

Area scan camerasHikrobot MV-CH250-25TC-F-NF 25 MP 10GigE area scan camera, PYTHON25K, Color, F-mount, With fanMV-CH250-25TC-F-NF
Sensor format
APS-H
Lens mount
F-mount
Interface
10GigE
Resolution
Over 25 MP
$7,349.00 · quotedView and quoteBuild a system with it

Decision: two 6 MP cameras when fixtures allow slices and cycle time wants higher frame rates; one 25 MP camera when the part cannot be divided optically or you want a single archived image per part. Both layouts clear the pixel rule, so choose on cycle time and mechanics, not on megapixel count.

Does the lens have to keep up with the sensor?

Yes: the sensor's pixel pitch sets the sampling, and the lens must still deliver contrast at that pitch. A 12 MP 1/1.7" sensor needs a lens rated for 12 MP and matched to its image circle, or the extra pixels sample blur instead of detail.

Three checks close the gap. First, image circle: the lens must cover the sensor diagonal, so a 1/1.7-inch sensor wants a lens built for at least that format. Second, rating: a lens sold for a lower megapixel class smears the detail a 12 MP sensor samples, and the money you spent on pixels evaporates in blur. Third, contrast at the sensor's Nyquist frequency decides resolved detail versus smeared detail — the Nyquist limit guide shows the match and the lens contrast walkthrough teaches you to judge it. Small pixels lean hardest on the lens, the trade-off the small-pixel camera guide works through. Match formats and ratings in machine vision lenses, then narrow by mount and image circle in the lens configurator.

Can lighting make up for fewer pixels?

No: resolution buys spatial sampling and lighting buys contrast. Contrast is usually the weaker half — a high-contrast defect shows at 3-4 pixels while a faint crack can vanish at 9, so fix lighting before adding megapixels.

Pixels sample space; lighting creates the contrast the sample must show. A flaw differing from its background by only 2-3% brightness sits near the noise floor at any resolution, while a well-lit flaw reads clearly at 4 pixels. Match geometry to the flaw: low-angle light turns a shallow pit into a bright highlight on matte metal, the approach in detecting dents and pits in metal surfaces with low-angle lighting, and wide fields need balanced coverage as large field of view lighting works out. Put the part under the chosen light and view it at full zoom on a monitor; if you cannot see the defect, megapixels will not rescue the inspection.

When is the high-resolution camera the wrong answer?

When the cycle time outruns the sensor: 25 MP frames move at about 4 per second over GigE and about 35 over 10GigE. A line that presents a part each second pushes you to split the field or step the interface up, not just the sensor.

Split the field when fixtures allow it: two 5 MP cameras beat one 25 MP camera on frame rate, interface cost and depth of field, because shorter focal lengths and smaller sensors focus more forgivingly. Switch to line scan when the part is continuous — a web, an extrusion, rolled sheet — and the pixel binning on a line scan camera guide covers the sensor behavior. When the part is larger than any sensible single field, the template matching guide for parts larger than the field of view shows the stitched way out. And when the check belongs at the station instead of a PC, the same rule sizes smart cameras: the built-in lens fixes the field, so compare object-space pixel size rather than the megapixel badge.

What do you check before ordering the camera?

Confirm the smallest defect and its contrast on real parts, frame the field with 10% margin, match the lens rating to the sensor's pixel pitch, and check exposure and bandwidth at the line's cycle time. Then the resolution you computed is the one to order.

  • Fix the smallest defect and the detection rate in writing; the whole calculation hangs on that number.
  • Light the part and view the defect on a monitor at full zoom; if you cannot see it, optics will not see it either.
  • Add 5-10% field margin for wander and recompute the pixel count before choosing a sensor class.
  • Match the lens rating and image circle to the sensor; a mismatch erases the margin you just paid for.
  • Check frame rate and interface bandwidth against the line's cycle time using the data-rate figures above.
  • Specify a global shutter for anything that moves during exposure.

When the three numbers are on the table — defect size, field, cycle time — the camera finder filters by resolution, shutter and interface, the camera configurator walks the whole chain, and the team on the contact page will check your arithmetic against the parts you name.

Questions

Do I need more pixels to measure a defect than to find it?

Flagging a defect works at 3-4 pixels across; a measurement you hold to a tolerance wants roughly 8-10 pixels across the feature plus stable optics, because calibration and edge-finding error consume margin. Subpixel edge fitting helps, but its real-world accuracy rests on lens contrast, lighting stability and calibration. If the tolerance is tight, plan 10 pixels and a low-distortion lens rather than betting on interpolation alone.

Is a higher resolution always the better camera for defect detection?

No. Doubling linear resolution quadruples the data: frame rate falls, exposure per pixel shrinks so you need more light or gain, and processing time per frame grows. Buy the resolution the pixel rule asks for and spend the difference on lighting contrast and a better lens — they raise detection probability more than surplus pixels do.

How do I convert megapixels into pixels across the image?

For a 4:3 sensor, width equals the square root of megapixels times one million times 4/3. A 2.5 MP sensor works out to about 1830 pixels across, 5 MP to about 2580 and 12 MP to 4000. Many sensors are 3:2 or 16:9 instead, so confirm the printed pixel dimensions of the exact model before you commit.

Can a 12 MP camera cover the 600 mm field if I accept 3 pixels per defect?

At 4000 pixels across a 600 mm field, each pixel covers 0.15 mm, so a 0.5 mm defect lands on 3.3 pixels. That clears the 3-pixel floor with about 10% margin, but not the 4-pixel floor. It is a workable compromise when lighting contrast is strong and the working distance is fixed; with weak contrast, focus drift or part wander, split the field or step up to 25 MP.

What data rate does a 25 MP inspection camera need?

A 25 MP frame holds about 26 million pixels, roughly 26 MB per 8-bit image. A GigE link moves around 110 MB per second, so about 4 frames per second; USB3 about 14; 10GigE about 35-40. Size the interface from your cycle time, not from the sensor: if the line presents a part every second, GigE cannot carry a 25 MP inspection.