ApplicationsTroubleshooting

Ring defect detection when template matching gives false rejects

Ring defect detection that works: why template matching gives false rejects and how polar unwarping with telecentric optics finds 60 µm nicks.

LumaSpec Vision12 min read Share on LinkedIn

On this page 8 sections
  1. 01Why does template matching reject good rings?
  2. 02How many pixels do you need across the smallest defect?
  3. 03Why use a telecentric lens to image a ring?
  4. 04What lighting keeps illumination even around a ring?
  5. 05How does polar unwrapping expose ring defects?
  6. 06When should deep learning take over from rules?
  7. 07How do you prove the false rejects are gone?
  8. 08Questions

Ring parts — seals, O-rings, washers, gaskets — are where template matching earns its bad reputation for false rejects. The part is rotationally symmetric, so the matcher always finds it. But a nick or flow line on the circumference changes a fraction of a percent of the scored pixels, far less than the part-to-part texture spread of molded elastomer. The station then rejects good rings all shift. This guide works one example end to end — a 22 mm seal ring with a 60 µm defect floor — through the pixel budget, the telecentric lens, the lighting, the polar-unwrap algorithm that replaces the template, and the acceptance test that proves the false rejects are gone.

Why does template matching reject good rings?

Because a circumferential defect changes well under 1% of the pixels the matcher scores. Meanwhile mold texture, lighting drift and small position offsets move the score by more than that; the OK and NG score distributions overlap, so every threshold that catches defects also rejects good rings.

Put numbers on the worked example: a molded seal ring, 22 mm outside diameter, annulus band from 9 mm to 11 mm radius. The ring band the template scores covers π × (11² − 9²) = 125.7 mm². A reject nick 0.6 mm of arc by 0.3 mm deep covers 0.18 mm² — 0.14% of the scored area. A normalized correlation score is a whole-region average, so a nick that reads fully black still shifts it by roughly a tenth of a percent. Good-to-good texture spread on molded elastomer runs several percent, an order of magnitude larger. Any threshold low enough to catch the nick sits inside the good-part score cloud.

The diagnostic costs one afternoon: score 200 good parts plus every defect sample you own, plot both histograms, and look at the separation. On subtle ring defects the separation is negative. That overlap — not your threshold settings — is the failure, which is why re-tuning the same matcher never holds. The same overlap mechanism drives false rejects in PCB solder inspection, and the fix there is the same: measure features instead of scoring whole regions.

How many pixels do you need across the smallest defect?

Four pixels minimum across the smallest rejectable feature; for a 60 µm nick that fixes the object-space pixel size at 15 µm or finer, and that number together with the field of view sets the camera resolution and the lens magnification in one calculation.

Write the defect spec first, because nothing downstream can be chosen without it. The example spec: 22 mm ring outside diameter, annulus from 9 mm to 11 mm radius, smallest rejectable nick 60 µm across in its narrowest dimension.

object pixel size = smallest defect / 4 pixels across field = field of view / object pixel size magnification = sensor width / field of view

Work it through: object pixel = 60 µm ÷ 4 = 15 µm. Field of view = 22 mm + 2 mm margin each side = 26 mm. Pixels across the field = 26 mm ÷ 0.015 mm = 1733 pixels, so a 3 MP sensor already clears the floor — but the strip method rewards headroom, because detection margins tighten with oversampling.

A mono camera is the right choice for grayscale nick work. The MV-CS200-10UM is a 20 MP mono camera with a USB3.0 interface, a 1"-format sensor and a C-mount. Its rolling shutter is harmless on a fixtured, strobed part; on a moving line you pick a global-shutter model from the area scan cameras finder instead.

Area scan camerasHikrobot MV-CS200-10UM 20 MP Area Scan Camera, USB3.0, IMX183, 2nd Gen., MonoMV-CS200-10UM
Sensor format
1"
Lens mount
C-mount
Interface
USB3
Resolution
16-25 MP
$759.00View partBuild a system with it

At 5472 × 3648 pixels of 2.4 µm pitch, a sensor in this class spans 13.1 mm — the width the example uses. Magnification is then 13.1 mm ÷ 26 mm = 0.50x, the delivered object pixel is 13.1 ÷ 5472 ÷ 0.5 = 4.8 µm, and the 60 µm floor spans 60 ÷ 4.8 = 12.5 pixels, three times the four-pixel minimum. Converting magnification into micrometers per pixel on the part is the object-space pixel size step. Run your own defect size and field of view through the camera resolution calculator before you commit.

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

Why use a telecentric lens to image a ring?

Because a conventional lens rescales the image with every small change in part height: at a 110 mm standoff, 1 mm of height error is a 0.9% scale change — 0.2 mm across a 22 mm ring, more than three times the 60 µm floor — and it lands exactly where the polar grid samples.

Two failure paths, both silent. First, scale: with an entocentric lens, magnification follows working distance, so a ring sitting high or low smears the nick across neighboring polar columns and cuts its contrast. Second, perspective: an off-axis view turns a true circle into a slight ellipse, so the sampled radius wobbles around the circumference and the strip grows a slow wave that can bury a shallow nick. The entocentric vs telecentric comparison shows the geometry; the short version is that measurement on rings earns its telecentric.

Perspective with a standard lens compared with a telecentric lens Left: the same part at two distances appears at two sizes through a standard lens. Right: a telecentric lens accepts only rays parallel to its axis, so the part appears the same size at both distances.Standard lensfarnearsensorThe same part looks bigger when nearer:its measured size depends on distanceTelecentric lensOnly rays parallel to the axis enter:the same size at any distance
Perspective with a standard lens compared with a telecentric lens. Left: the same part at two distances appears at two sizes through a standard lens. Right: a telecentric lens accepts only rays parallel to its axis, so the part appears the same size at both distances.

The 0.5x slot in the worked example is held by the LS-TCL-2194, a 1"-format C-mount telecentric lens with a 110 mm working distance and a built-in coaxial light port.

Telecentric lenses0.5x, WD 110 mm, 1", C-mount telecentric lens with coaxial light (LS-TCL-2194)LS-TCL-2194
Sensor format
1"
Mount
C-mount
Image circle
11-16 mm
Type
Object-side telecentric
$1,539.00View partBuild a system with it

For smaller rings the same standoff is available with more magnification, which buys finer object pixels:

Specification LS-TCL-2194 LS-TCL-0651
Price $1,539.00 $969.00

All 2 share: Mount C-mount. Values as printed in each product's data sheet; open a part for its drawing and full specifications.

On the 13.1 mm sensor, 0.66x spans 13.1 ÷ 0.66 = 19.8 mm — rings up to about 17 mm — and the object pixel drops to 19.8 ÷ 5472 = 3.6 µm, so the same 60 µm floor covers 17 pixels. For rings past 25 mm you step down in magnification instead. The LS-TCL-1422 is a bi-telecentric 0.166x lens with a 258 mm working distance. On the same sensor that is 13.1 ÷ 0.166 = 78.9 mm of field, enough for rings to about 70 mm, and bi-telecentric construction holds magnification constant on both sides of focus — worth it when parts arrive at varying height.

Residual distortion still bends the sampled circle slightly; map it out once per lens with a dot target and a scale constant, the way lens distortion correction for pixel-to-mm measurements describes. Other magnifications sit in the telecentric lenses category and the lens finder.

What lighting keeps illumination even around a ring?

A diffused ring light on the lens axis at a moderate 30° angle, with an outer diameter four to five times the ring diameter — 100 mm over the 22 mm example — is the default; the evenness target is column-to-column intensity within ±1% on good parts.

The polar method compares angular columns against each other, so start from illumination that is already even. The sizing rule puts the ring in the flat center of the beam: 100 mm ÷ 22 mm = 4.5× the part diameter. A diffuser is not optional — bare-LED imaging leaves fine column structure that survives the row-mean flattening and reads as false arcs.

The LS-RNG-0143 is a 100 mm ring light with a diffuser, a 30° beam and a 24 V supply.

Ring lights100 mm dia. ring light with diffuser, 30° (LS-RNG-0143)LS-RNG-0143
Size
100-200 mm
Type
Diffused
Angle
30°
Voltage
24 V
$169.00View partBuild a system with it

Vary the angle to vary the defect set: a low-angle pass brings up edge nicks and raised flash, and stacked ring lights switching angles shows how one station runs both. Glossy elastomer that mirrors the light needs cross-polarization; black rubber compounds follow the rules in black O-ring lighting. Strobe the light rather than running it continuous: short pulses freeze residual motion and let you overdrive for intensity, the way LED overdrive and current control describes. Shield the station so nobody works eye-level with the pulsing array — an overdriven ring light is a bright pulsed source. The full range sits in ring lights.

How does polar unwrapping expose ring defects?

It re-maps the annulus into a rectangular strip — angle along the columns, radius along the rows — so a nick spanning a few degrees of arc becomes a compact dark bar at a known row range, and detection reduces to comparing each angular column against its neighbors.

Circle fitting is the same first move as dimensional measurement of small parts; the unwrap then does the work the template could not:

  1. Segment the ring and fit a least-squares circle to its outer edge from subpixel edge points. Reject the image if the fit residual exceeds 0.5 px — that is a fixture or focus problem, not a part problem.
  2. Sample the annulus from 9 mm to 11 mm radius into a strip of 4096 columns × 417 rows: the 2 mm band at the 4.8 µm object pixel gives 2 ÷ 0.0048 = 417 rows, and each column spans 69.1 ÷ 4096 = 16.9 µm of arc at the outer edge (circumference 2π × 11 mm = 69.1 mm).
  3. Flatten: subtract each row's mean to remove the radial intensity falloff.
  4. Reference: for each column take the mean over rows, then compare it with a rolling median over ±100 columns — about 2.5% of the circumference, wider than any single defect.
  5. Flag a column when its deviation from the rolling median exceeds 3σ of the good-part column noise, with σ measured once on 30 or more good-part strips, and require a run of at least 3 columns, which is 3 × 16.9 µm ≈ 50 µm of arc, so single-column noise cannot trip the detector.
  6. Optionally threshold the flattened strip and run blob analysis with a 20-pixel minimum area for pits anywhere in the band; connectivity 4 or 8 in blob analysis changes what counts as one defect on thin arcs.

The example nick lands loudly: 0.6 mm of arc is about 35 columns, 0.3 mm of depth is 62 rows, and darkening 62 of 417 rows by half-scale drags that column mean down by roughly 62 ÷ 417 × 50% ≈ 7% — far outside a ±1% column spread. At the 60 µm floor the signal is about 4 columns by 12 rows, a 1.5% column shift, which is why lighting evenness and the 3σ reference carry the margin.

Why a rolling median instead of a stored golden strip? Subtracting a good-part template works until presentation shifts by a fraction of a pixel, and then contour artifacts flood the flags — the failure mode behind image subtraction false defects. The per-row mean plus rolling median only assumes the ring is circular and the lighting slow-varying, both of which the telecentric lens and diffused light already bought. Subpixel edges and the fitted center do drift with temperature and focus over weeks; that drift budget and its recalibration routine are covered in micron-level measurement accuracy drift.

When should deep learning take over from rules?

When the rules find candidates reliably but cannot grade them: keep detection geometric, and train a small classifier on the flagged crops to separate real nicks from dust, oil film and mold texture — full-image deep learning only earns its keep when the ring surface is printed or intentionally variable.

Expect the rule set to flag 1–5% of parts; that is the classifier's whole workload, which is why a small model on a CPU is enough and the CPU and GPU decision for deep learning setups usually lands on CPU here. Start with 300–500 labelled crops per class taken from your own line — nicks, dust, oil, good texture — and route anything the classifier scores as borderline to a review bin rather than auto-rejecting. The strategy follows AI defect inspection on products with natural appearance variability: the network grades what geometry finds.

Two classic confusers are worth fixing at the source before you photograph them into a training set. Machining oil causing false rejects is a lighting and cleaning problem, and dust false rejects is an airflow and staging problem. A classifier can memorize both, but it will then also pass oil on a part that should fail.

How do you prove the false rejects are gone?

Run the finished detector on a golden set — 200 good parts shot across the shift's lighting range plus every physical defect you can make — and accept the setup only when it misses nothing at or above the 60 µm floor while flagging under 1% of the good parts.

Work the list before release, and re-run the first three items after any hardware change:

  • Flag histograms of the golden set separate by 3σ or more; if they touch, fix the lighting or the optics, never widen the threshold.
  • Circle-fit residual stays under 0.5 px on every golden image; a jump means focus or fixture movement.
  • Column-to-column spread on good parts stays within ±1% with the diffuser fitted.
  • Strobe pulse holds motion blur under one object pixel at belt speed (blur = speed × exposure).
  • Every flag is logged with its raw image and its strip, and the log is reviewed weekly — on the OEE sheet, false rejects count as good after approved release, so the log is what keeps the accounting honest.
  • Fifty fresh good parts are re-shot after any lens, light, camera or fixture change.

From here the lens configurator walks the same magnification-to-pixel arithmetic for your ring, and the applications topic collects related build notes. For a specific part, send sample images through the contact page and we will size the station with you.

Questions

Is there any ring inspection where template matching is the right tool?

Yes — gross shape and presence. If the defects you care about remove more than a few percent of the matched region (a missing segment, major flash, wrong part), a normalized-correlation threshold near 0.85 separates cleanly. The failure zone is subtle surface defects under about 1% of region area, where the score gap is smaller than the texture spread between good parts. There, replace the matcher with geometry, not with more tuning.

How much mechanical clearance does a telecentric lens need in front of the ring?

Roughly the field of view plus mounting hardware. An object-side telecentric lens only stays telecentric over an entrance aperture at least as wide as the object, so a lens built for a 26 mm field arrives with a front barrel around 30 mm across or larger, and at a 110 mm working distance you also need that much free space along the axis. Weigh this before specifying a telecentric lens for a tight nest or a multi-lane tray.

What strobe exposure freezes a moving ring?

Keep blur under one object pixel: exposure equals object pixel divided by line speed. At 4.8 µm object pixels and 200 mm/s of belt motion that is 4.8 µm ÷ 200,000 µm/s = 24 µs, so a 20 µs strobe pulse with the camera exposure gated to match holds blur below one pixel. Overdriving the LED for those microseconds recovers the intensity; continuous illumination usually cannot reach it.

Can several rings be inspected in one image?

Yes. Segment each ring separately, fit its own circle, and unwrap each annulus to its own strip; the per-part cost is a few milliseconds of remapping on a current CPU. Keep ring centers at least 20 pixels apart so edge points do not bleed between parts, and flatten each strip with its own row means, because lighting is never equally even across a wide field. Label results by fitted center position.

Does the polar transform work on square or rectangular seals?

Not directly — the transform assumes rotational symmetry, and unwrapping a square profile smears its corners into long streaks. For square and rectangular seals, walk the detected outline with a contour follower and build the strip from distance-along-perimeter and distance-inward-from-edge instead of angle and radius. The column-deviation test then works unchanged, because it only needs a one-to-one strip map, not a circle.