System designExplainer

Pattern search sensitivity vs accuracy: tuning position detection

Search sensitivity stops false matches; search accuracy stops jitter in pattern search. Here is how each works, the numbers it moves, and a tuning example.

LumaSpec Vision11 min read Share on LinkedIn

On this page 9 sections
  1. 01The decision first
  2. 02How the search runs: compress, skip, refine
  3. 03Search sensitivity: the compression ratio behind the first pass
  4. 04Search accuracy: refinement passes and sub-pixel interpolation
  5. 05Worked example: holding ±3 µm on a fiducial over a 15 × 9 mm field
  6. 06The hardware that carries the search
  7. 07When the knobs are the wrong answer
  8. 08A ten-minute check before you commit
  9. 09Questions

A pattern search that locks onto a similar but wrong feature, and one that finds the right feature but jitters a pixel between captures, are different failures — and a search tool gives you two different controls for them. Search sensitivity changes how far the images are compressed before the first pass. Search accuracy changes how many refinement passes follow, and whether the final position is interpolated between pixels. This explainer follows the coarse-to-fine algorithm behind the two settings, gives the numbers each knob moves — compression ratio, skip width, repeatability in fractions of a pixel — and works a ±3 µm fiducial tolerance through to a camera, a lens and committed settings.

The decision first

Set each knob for its own symptom. A wrong match — the returned position sits a fixed distance from the true one, usually the pitch to a neighbouring look-alike — is a first-pass failure: raise sensitivity. Jitter — the correct feature matched every time, coordinates wandering ±1–2 px — is a final-pass failure: raise accuracy, then average captures. Neither knob fixes the other's symptom, and paying cycle time on the wrong one is the most common tuning mistake on the bench.

Symptom Where the pyramid fails Knob and direction Cost
Position jumps a fixed distance to a look-alike First pass at heavy compression Sensitivity one level higher First pass evaluates more pixels; halving the decimation factor costs about ×16
Right feature, coordinates wander ±1–2 px Final pass stops at whole pixels Accuracy one level finer, sub-pixel on A few small refinement passes, modest time
Noise frame to frame on a stopped part Sensor noise, micro-vibration Average n captures (continuous capture) Cycle time ×n; jitter falls with √n
Match flips or appears rotated Rotation range and tolerance settings Tighten rotation range Usually free

The rotated case has its own tolerance settings — pattern matches that flip 180 degrees walks them.

How the search runs: compress, skip, refine

Pattern search scores a taught reference window against every position in the search region with normalized correlation, which is invariant to overall brightness and contrast shifts — the property that made it the default position detector. Scoring every pixel at every position is far too slow, so the tool runs a pyramid:

  1. Compress. Decimate the reference window and the search image.
  2. First search. Slide the compressed window at a fixed step width (the skip) and keep the best score; with rotation enabled, repeat at each angle.
  3. Second search. Re-search a smaller area around that hit at a lower compression ratio, sometimes at several ratios in sequence.
  4. Final detection. Search the neighbourhood at full resolution, then interpolate the correlation peak between pixels.
cost of one pass ≈ pixels per window × window positions decimating by d in x and y → pixels / d² and positions / d² cost ratio ≈ d⁴ → a 4× decimation makes the first pass ≈ 1/256 of a full search

That d⁴ law is why the pyramid exists and what sensitivity spends. It also explains why a large skip is safe for speed and dangerous for correctness: the first pass can land up to s/2 px from the true peak, and refinement recovers that offset — for the candidate that won. Compression deletes exactly the fine detail that separates a mark from its look-alike, so at heavy compression two different features can score within a fraction of a percent of each other, and the wrong one sometimes wins.

Search sensitivity: the compression ratio behind the first pass

Where a tool exposes presets, search sensitivity is the first-pass compression ratio dressed as a level — expect a short scale, five to seven steps from low to high, rather than a raw number. Low sensitivity decimates hard: the fastest first pass, the highest false-match risk. High sensitivity keeps more original pixels in the first pass, so the detail that separates look-alikes survives — priced by the d⁴ law, because halving the decimation factor multiplies first-pass work by about 16.

Commit to the lowest level that never returns a wrong candidate over a long soak — 1,000 cycles at line speed is a realistic length. Every level above that is cycle time spent for nothing. Two free levers lower the level you need: teach a window with content that exists nowhere else in the search region (teaching long thin parts by feature, not by the whole part is the same lesson), and shrink the search region to the wander plus margin, which also speeds every pass — shrinking the search area to speed the update rate quantifies that trade.

Search accuracy: refinement passes and sub-pixel interpolation

Search accuracy sets how much of the pyramid runs below the first pass — the number of intermediate ratios, the density of the final search, and whether the correlation peak is interpolated between pixels. Preset scales run Coarse to Fine, five steps on common schemes. Its whole job is variance reduction on a candidate that is already correct.

repeatability (object units) = sub-pixel fraction × pixel size at the part pixel size at the part = field of view ÷ pixels across the field σ of the mean of n captures = σ of one capture ÷ √n

Numbers to hold onto: a whole-pixel final pass lands at about ±1 px repeatability; with sub-pixel interpolation on a sharp target, roughly ±0.1 px is the usual result. Edge-based tools do better in object units when the optics suit them — sub-pixel edge evaluation reaches 2–3 µm repeatability — and estimating edge position accuracy from image sampling shows where such numbers come from. For a dark centred mark, a grayscale centroid with inversion for sub-pixel reaches the same goal without a correlation peak. Averaging stacks on top: 9 captures cut random jitter to a third, 25 to a fifth, and continuous capture reports the average, max and min for you.

One limit, stated once: refinement converges on whatever the first pass chose. Fine accuracy makes a wrong match precisely and repeatably wrong. Repeatability is not correctness.

Worked example: holding ±3 µm on a fiducial over a 15 × 9 mm field

Inputs. The task is a lamination pre-alignment: locate a 3 mm fiducial on a glass substrate to ±3 µm before the parts join. The stage repeats to ±4 mm in x and ±1 mm in y; keep 2 mm of margin on every side. The substrate stops under the camera, so exposure is not motion-limited. Camera: the LS-CMR-0166, a 12 MP USB3 area scan camera with 4000 × 3000 pixels on a 1/1.7-inch sensor.

Field of view. Width = 4 + 4 + 3 + 2 + 2 = 15 mm; height = 1 + 1 + 3 + 2 + 2 = 9 mm.

Optics. A 1/1.7-inch sensor carries roughly 7.5 × 5.6 mm of active area, so the magnification is m = 7.5 ÷ 15 = 0.5. The short axis then covers 5.6 ÷ 0.5 = 11.2 mm — margin over the 9 mm required. At a 100 mm working distance the focal length is f = WD × m ÷ (1 + m) = 100 × 0.5 ÷ 1.5 = 33 mm; the nearest standard C-mount lens is 35 mm, which sets the working distance to 35 × 1.5 ÷ 0.5 = 105 mm.

Scale. One pixel at the part = 15 mm ÷ 4000 px = 3.75 µm. A whole-pixel final pass repeats to about ±3.75 µm — larger than the tolerance itself. Sub-pixel at ±0.1 px repeats to about ±0.375 µm.

Budget rule. The vision step should consume no more than a quarter of the tolerance: ±0.75 µm here. Coarse accuracy fails outright; Fine accuracy with sub-pixel passes with room to spare.

Sensitivity. Traces pass within 3 mm of the fiducial and correlate with it at heavy compression. Start one level above the lowest, soak 1,000 cycles at each level, keep the lowest level with zero wrong candidates.

Verification. Capture 20 times on a stationary substrate and accept when the max − min range stays under 30% of the 6 µm band, that is 1.8 µm. With σ ≈ 0.375 µm the expected range of 20 samples is about 3.5σ ≈ 1.3 µm — pass. The whole-pixel case, σ ≈ 3.75 µm, would spread over roughly 13 µm — fail.

Committed settings. Sensitivity one level above minimum, confirmed by the soak; accuracy Fine with sub-pixel on; no averaging, because sub-pixel already leaves margin — averaging 9 would push σ to about 0.125 µm, which this tolerance does not need and the cycle time cannot give away. If a variant of this line never stops the substrate, freeze motion instead: exposure ≤ 3.75 µm ÷ 80 mm/s ≈ 47 µs at 80 mm/s, a strobe pulse rather than a shutter.

Run the same chain on your own numbers with the camera resolution 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

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

Where the search runs decides your integration path. Vision sensors and smart cameras execute the whole pyramid in the housing and hand the PLC a coordinate — the leanest route for index tables and stand-alone stations. The LS-SMC-0063 is a 1.6 MP smart camera with a 16 mm lens; the MV-SC3050XC-16M-ATN-H is a 5 MP color vision sensor on Fast Ethernet. The smart cameras category lists both families.

When the field is large, the marks are many, or every image must be archived, an area scan camera plus PC software is the better base — area scan cameras run from compact USB3 parts up to a 20 MP model with a 1-inch sensor, the MV-CS200-10UM.

At a tenth-of-a-pixel target, every micron of camera motion reads as part motion, and averaging cannot remove a drift. Put the camera on something rigid: the LS-MNT-0040 is a slide-table stand with a 700 mm height and a 400 × 450 mm base, and the camera stands category covers brackets and stages.

Smart cameras & vision sensors1.6 MP smart camera, 60 fps, 16 mm lens, white light (polarized, transparent light) (LS-SMC-0063)LS-SMC-0063
Interface
GigE
Resolution
Up to 3 MP
$1,110.00View part
Smart cameras & vision sensorsHikrobot MV-SC3050XC-16M-ATN-H 5 MP color vision sensorMV-SC3050XC-16M-ATN-H
Interface
Fast Ethernet
Resolution
5 MP
$1,809.00View part
Camera standsMachine vision camera stand, professional slide-table type, height 700 mm, 400 x 450 mm base (LS-MNT-0040)LS-MNT-0040
Type
Camera stands
$629.00View partBuild a system with it

When the knobs are the wrong answer

Four situations waste tuning time. First, the target itself changes: a frame covers part of the mark, the finish changes, the image inverts black-to-white, or size and focus drift — normalized correlation collapses and no sensitivity level saves it. Geometry search extracts the edge contour and matches profile instead of grey value, which survives all four; edge-based pattern matching when lighting changes covers the mode choice.

Second, optics: sub-pixel interpolation fits a curve through the correlation peak or the edge grey-level slope, and a defocused edge gives it a shallow slope. Stopping down hurts twice — at f/8 the Airy disc is 2.44 × 0.55 µm × 8 ≈ 10.7 µm, about six of the example's 1.9 µm sensor pixels — so depth of field bought with aperture is contrast lost to interpolation.

Third, mechanics: a drifting mount or a vibrating frame produces a one-directional walk that averaging hides on the report and the robot still feels.

Fourth, search scope: if the part never rotates, disable rotation search — every enabled angle multiplies the first pass.

A ten-minute check before you commit

  • Teach a window whose content appears nowhere else in the search region.
  • Shrink the search region to wander plus margin.
  • Soak 1,000 cycles at line speed; keep the lowest sensitivity with zero wrong candidates.
  • Choose the finest accuracy the cycle-time budget allows; leave sub-pixel on.
  • Size averaging with σ ÷ √n against the tolerance, not by habit.
  • Accept only when 20 stationary captures hold max − min under 30% of the tolerance band.
  • Keep motion blur under one pixel at worst line speed; strobe if the shutter cannot.
  • Re-run the 20-capture check after any change to the mount, lens or lighting.

Committed coordinates have somewhere to go: how the 2D vision-guided pick-and-place cycle works shows where they land in the robot loop. To turn a settled spec into hardware, the camera finder and the configurator walk the same chain of numbers, and the contact page reaches the applications team for the odd cases.

Questions

The search occasionally jumps several millimetres to a neighbouring feature. Sensitivity or accuracy?

Sensitivity. A jump that lands a fixed distance away, equal to the pitch of a nearby similar feature, is a first-pass false match: at heavy compression the two features score almost the same and the wrong one sometimes wins. Raise sensitivity one level, which lowers the compression ratio so the first pass keeps the detail that separates them, and confirm with a thousand-cycle run at each level. Refinement passes cannot fix this — they polish the wrong position.

How many captures should continuous capture average, and what does it buy?

Averaging n captures divides random jitter by the square root of n: 4 captures halve it, 9 cut it to a third, 25 to a fifth. Set n by your cycle-time budget, not by feel — going from 9 to 25 captures buys only a further 40% reduction in σ while nearly tripling the image time. Continuous capture also reports the max and min of the run, which is the quickest way to see whether the remaining spread is random noise or a mechanical shift.

Can I run high sensitivity with coarse accuracy?

Yes, and it is the right combination when a stopped part must be found unambiguously but only to a few pixels — an index-table orientation check, for example. High sensitivity makes the first pass expensive, so pay for it by keeping accuracy coarse: the final search then stops at whole pixels and skips most refinement. The reverse — low sensitivity with fine accuracy — spends time polishing a position that the first pass may already have attached to the wrong feature.

What resolution do I need for a ±0.1 mm position tolerance?

With sub-pixel interpolation worth about a tenth of a pixel, a pixel at the part can measure up to 1.0 mm and still hold ±0.1 mm: tolerance divided by 0.1 px. A 40 × 30 mm field then needs only about 40 × 30 pixels for the tolerance itself, so almost any modern sensor has margin. Spend the extra pixels on a larger, more distinctive teach window and on optics margin, not on the tolerance. The camera resolution calculator runs this arithmetic for any tolerance.

Does sub-pixel interpolation still work when the target is defocused or low contrast?

It degrades before it fails. Interpolation fits a curve through the correlation peak or the edge grey-level slope, so it needs a clean slope to work with. As focus softens or contrast drops, the fitted peak flattens and repeatability slides from tenths of a pixel back toward whole pixels — you will see it as a widening 20-capture range. Fix focus, lighting and exposure first; tightening search accuracy after that only measures your optics errors more precisely.