System designExplainer

Scale invariance in pattern matching: why 5% breaks and what fixes it

Correlation pattern matching keeps its score only within about ±5% scale change; beyond that its scale invariance fails and a geometric matcher takes over.

LumaSpec Vision11 min read Share on LinkedIn

On this page 9 sections
  1. 01Scale invariance, shift invariance and rotation invariance
  2. 02Why correlation matching stops near 5%
  3. 03Correlation versus geometric matching at a glance
  4. 04Worked example: sizing the scale range for a 105 to 132 mm bracket
  5. 05Where the two methods run on the floor
  6. 06Set the scale range, then watch the search time
  7. 07When the usual answer is wrong
  8. 08Checks before you commit
  9. 09Questions

If your template was taught on one part size and the line now runs three, correlation-style pattern matching will start missing parts before anything else in the station changes. This family of matcher — the default in most vision software — holds its score only while the part images within about ±5% of the taught size, and the scale value in its result stays pinned at 100 however much the part grows or shrinks. For anyone locating parts for robot picking, alignment or gauging, the fix is algorithm choice, not a lower score threshold. Below you will find the arithmetic to size your own case, a worked example at −12.5% to +10% scale change, the decision rule between correlation and geometric matching, and the runtime traps that open up once you widen the search.

Scale invariance, shift invariance and rotation invariance

A matcher's guarantees come in three kinds, and they fail differently. Shift invariance means the matcher finds the feature anywhere in the image; every matcher you will meet has it. Rotation invariance means it finds the feature turned by any angle inside the range you allow, and you set that range yourself. Scale invariance means it finds the feature when the part images larger or smaller than the template did at teach time.

Correlation matchers are fully shift invariant, they rotate across whatever angle range you configure, and they stop being reliable a few percent away from the taught size. Their result structure carries a scale field, but scale is not among the parameters the algorithm searches, so the field holds a constant: the template's own scale, returned as 100 whatever the part does. A constant in a result field is not a measurement, and treating it as one is how size drift hides on a line.

Why correlation matching stops near 5%

The correlation score measures how well gray levels line up, pixel against pixel, between template and image. Enlarge the part by 10% and every edge lands several pixels away from where the template expects it, so the correlation peak flattens and the score drifts into the background noise. The slip grows in proportion to feature size: 5% of a 200-pixel feature is 10 pixels of misregistration at its rim, which pyramid-style search can still ride; 12% means 24 pixels, and the peak is gone. Vendor guidance and long field practice put the usable band near ±5%, so treat 5% of scale change as the planning limit, not a number you recover by loosening the score threshold.

Size your own case with two lines of arithmetic:

s = feature width in the image / feature width in the template percent change = (s − 1) × 100

Correlation stays usable while the absolute percent change stays at or under 5. Geometric matchers, covered next, treat scale as an explicit search range and report what they find.

Correlation versus geometric matching at a glance

Geometric matchers work from edges and feature descriptors instead of raw gray levels, and scale is one of their search parameters. The classic feature method outside industry is the scale-invariant feature transform (SIFT), which detects and describes local features so the same structure matches across large changes of scale and rotation; industrial geometric matchers apply the same idea to edge maps.

Correlation (normalized cross-correlation) Geometric / feature based
What it matches Gray levels at the taught size Edges, corners and feature descriptors
Usable scale band About ±5% Any range you set, for example 0.85–1.15
Scale in the result A constant, 100 Measured for every hit
Angle in the result Coarse, from the searched steps Measured for every hit
Score under lighting change Falls with glare and blur Holds better, because edges survive
Search time Lowest Grows with the scale and angle ranges

Because the score comes from edge agreement rather than gray levels, geometric matching also keeps position stable when lighting shifts — the same property behind edge based pattern matching for stable results when lighting changes. For pure shape work, Hu moments for shape matching under rotation and scale shows descriptors that ignore size by construction, and rotation and scale affine transform search in machine vision extends the idea to shear and non-uniform scaling.

Worked example: sizing the scale range for a 105 to 132 mm bracket

The inputs, from a drawing set and the station as built: the feature is a milled boss whose width the matcher must find on three sizes of the same bracket; nominal width 120 mm, smallest variant 105 mm, largest 132 mm; the station images at 0.50 mm per pixel, a number you read off your own station by imaging a ruler under the camera; the correlation band is ±5%; the template is taught on the nominal part.

The rule in words: convert each variant's width to pixels with the image scale, divide by the template width to get that variant's scale factor s, and compare the percent change against the band.

The arithmetic:

  • Template: 120 mm ÷ 0.50 mm/px = 240 px
  • Smallest variant: 105 mm ÷ 0.50 mm/px = 210 px; s = 210 ÷ 240 = 0.875; change = (0.875 − 1) × 100 = −12.5%
  • Largest variant: 132 mm ÷ 0.50 mm/px = 264 px; s = 264 ÷ 240 = 1.10; change = +10.0%

The result: the ±5% correlation band covers s = 0.95 to 1.05, which is 228 to 252 px of boss width. The small variant sits 18 px below that floor and the large one 12 px above the ceiling, so both ends fail.

The decision: correlation is out for this family, because the worst case, 12.5%, exceeds the 5% band. Set a geometric matcher's scale range to 0.85 to 1.15 — it covers s = 0.875 and s = 1.10 with 2.5 and 5 points of margin. Above 5% of worst-case scale change, fit a geometric matcher; at or below it, correlation stays the faster tool. If a 100 mm variant joins the family later, it images at s = 200 ÷ 240 = 0.833, below the 0.85 floor, so the range widens to 0.80 to 1.15.

Where the two methods run on the floor

The algorithm lives in the vision software, but the hardware decides where it runs and how much search you can afford. On the device tier, a smart camera captures, matches, decides and drives its outputs in a single housing, with no PC in the loop; the smart camera finder filters them by interface, resolution and shutter. Current options:

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
Smart cameras & vision sensorsHikrobot MV-SC5060XM-08M-WBN SC5000X series Smart Camera, 6 MP, Mono, 8 mm focal length, M12-mountMV-SC5060XM-08M-WBN
Interface
GigE
Resolution
6-10 MP
$1,629.00View part

The MV-SC3050XC-16M-ATN-H captures 5 MP color through a global shutter onto Fast Ethernet with an M12 mount. The MV-SC5060XM-08M-WBN pairs a 6 MP mono sensor with an 8 mm focal length, a GigE interface and a rolling shutter.

When several cameras feed one decision, when you want the measured scale of every part logged, or when the recipe needs a wide scale range, move the match onto the controller tier. A vision controller runs the library you configure and merges camera results in one program:

Vision controllersHikrobot MV-VC3301H-128G66 I3-8100, 8GB+128G SSD, No PoE, PCIe expansion supported, Incl. VM6200Pro licenseMV-VC3301H-128G66
LAN ports
5+ LAN ports
USB 3 ports
3-4 USB 3 ports
$2,419.00View part
Vision controllersHikrobot MV-VC5525-256G70-NN VC5000 Vision Controller, 12th-I5, 32GB+256G SSD, Supported PCIEMV-VC5525-256G70-NN
LAN ports
5+ LAN ports
USB 3 ports
3-4 USB 3 ports
$4,479.00 · quotedView and quote

The MV-VC3301H-128G66 runs an Intel Core i3 with 8 GB of memory and a 128 GB SSD, lists 5+ LAN ports and includes a VM6200Pro license. The MV-VC5525-256G70-NN steps up to an Intel Core i5 with 32 GB of memory, PoE camera ports and 8 built-in light channels.

Set the scale range, then watch the search time

Set the range from the parts plus a few percent of margin at each end — the worked example above shows the arithmetic — and resist the urge to pad it. A range of 0.5 to 2.0 set 'just in case' multiplies the positions the matcher must test, drags the update rate down and raises the odds of false hits; pattern matching low fps: shrink the search to speed the update rate works through that cost, and pattern search sensitivity vs accuracy: tuning position detection covers the trade from the other side. Search cost grows with the image area, the angle range, the scale range and the number of candidate matches you request.

Symmetric parts are the classic trap here, because a round or mirrored feature matches equally well upside down; symmetric part orientation matching: rotation tolerance in picking shows how to bound that before it reaches the gripper.

When the usual answer is wrong

Lowering the score threshold is the first reflex and the wrong one: below the band the correlation score decays toward noise, so a looser threshold admits false hits without recovering the true ones.

Stretching correlation with a multi-template pyramid — templates taught at several sizes, best score wins — bridges the middle ground between 'score still usable' and 'peak gone'. Search time scales with the number of templates, and a template set is still blind outside its taught sizes; past that middle ground, move to geometric matching.

One template cannot cover every size a family might grow into. When a variant falls outside the range you set, the fix is to recompute the range, not to loosen the matcher — the 100 mm bracket case in the worked example is exactly that check.

If the feature outgrows the image entirely, scale is no longer your problem; template matching a part larger than the field of view handles that failure mode.

Smooth parts with few edges starve a geometric matcher, which needs edges to agree on. There, control the size change at the source — fixtures and standoff discipline, or optics that hold magnification — and let correlation keep the job.

Checks before you commit

  • Compute s for the smallest and largest variants with the two-line formula above. Keep correlation only if both land within ±5% of 1.
  • Teach the template on the nominal part, focused and high-contrast, with enough pixels that its edges resolve — the failure mode and its fix live in pattern match error template image too small: fix ROI size.
  • Check the tool set of the device or library you configure for two things: an explicit scale range input, and a measured scale value returned with every hit.
  • Bench-test with golden parts at both ends of the size spread and read back the reported scale each time.
  • After widening any range, re-time the cycle before the recipe reaches the line.

The short version: measure the worst-case percent scale change between template and parts. At or under 5%, keep correlation; above it, switch to geometric matching and set the range from the measured spread, not from habit. Shortlist hardware from the smart camera and vision controller categories above, read more on the systems topic page, or contact us for a second opinion on a matcher choice.

Questions

Why does my pattern match result always report a scale of 100?

A correlation matcher compares the template with the image at the template's trained size only. Scale is not one of the parameters it searches, so the scale field of the result carries a fixed constant instead of a measurement, whatever the part in the image is doing. Treat it as a constant and do not build a size check on it. If the station must also judge size, add a measurement tool on the feature, or a geometric matcher whose scale output works as a real gauge.

How much scale change can normalized cross-correlation take?

Plan on about ±5% as the usable band, which is where published guidance and field experience place the limit before the score decays into noise. Between 5% and roughly 10%, a set of templates taught at two or three sizes sometimes bridges the gap at the cost of search time. Past about 10% of change, stop stretching correlation and move to a geometric matcher with an explicit scale range, whose measured scale output doubles as a size gauge.

What scale range should I set in a geometric matcher?

Work it out from the parts rather than from habit. Divide the smallest and largest feature widths you must accept by the template width, add a few percent of margin at each end, and use that band. A spread from 0.875 to 1.10 becomes a range of 0.85 to 1.15. Keep the band as narrow as the parts allow, because search time and the odds of false hits both climb as it widens.

Can I remove the scale change instead of matching it?

Often, yes. Scale change at the camera has two usual sources: parts that genuinely differ in size, and distance drift between lens and part. Fixtures and a controlled standoff remove the second source. Where the standoff must float, a telecentric lens holds magnification constant across its depth of field, so the part images at one size even as it moves toward or away from the lens. Matching the residual change is then a much smaller job.

Is geometric matching slower than correlation?

Yes, and the gap grows with what you ask it to search. Every extra degree of rotation range and every point of scale range multiplies the positions the matcher must test, and each extra candidate match adds scoring work. Correlation over a narrow window remains the fastest option; geometric search wins wherever the scale or angle of the part is genuinely unknown. Trim both ranges to the measured spread and the penalty stays small.