System designHow-to

Missing pattern cell detection using lattice matching

Build missing pattern cell detection with an anchored lattice, one-to-one center matching, measured tolerances, and separate malformed-cell checks.

LumaSpec Vision10 min read Share on LinkedIn

On this page 10 sections
  1. 011. Define occupancy separately from shape
  2. 022. Stabilize and size the image
  3. 033. Register an anchored reference lattice
  4. 044. Extract one reliable center per cell
  5. 055. Match centers within a measured tolerance
  6. 066. Turn unmatched sites into inspection results
  7. 077. Verify performance with controlled defects
  8. 08Choose hardware around the inspection workload
  9. 09Limits and checks before ordering
  10. 10Questions

A repeating pattern can produce a noisy difference image even when every cell is present. Small shifts, changing stroke widths and uneven contrast create pixel differences that resemble damage. For inspection tasks where missing cells matter, compare expected cell positions with detected cell centers instead of comparing every pixel.

This procedure builds an anchored lattice, assigns observed centers to expected positions, and reports unmatched sites. You will also keep malformed cells separate from missing cells, so accepting normal thickness variation does not accidentally accept damaged shapes.

1. Define occupancy separately from shape

  1. Write separate acceptance rules for cell presence, cell shape and inspection validity before choosing an algorithm.

A presence check asks whether a recognizable cell occupies an expected location. A shape check asks whether that cell has an acceptable outline, opening, area or internal structure. An inspection-validity check asks whether the image contains enough trustworthy evidence to make either decision.

These questions need different measurements:

Inspection question Useful measurement Main limitation
Is a cell missing? Expected position without an assigned observed center Weak contrast can resemble absence
Is a cell malformed? Shape, continuity or dimensional measurements Allowed thickness changes affect some measurements
Is the pattern displaced? Registered translation, rotation and lattice spacing Repetition can make the reference origin ambiguous
Can this region be inspected? Visibility, contrast and registration quality Uninspectable does not mean acceptable

If the problem is mainly unwanted edge differences, start with reducing contour artifacts in image subtraction. If the requirement is an overall regularity score, measuring pattern strength with spatial regularity addresses that different decision. Neither result, by itself, identifies every empty lattice position.

2. Stabilize and size the image

  1. Capture repeatable images, then confirm that the smallest relevant feature occupies enough pixels for your chosen measurement.

Hold lighting, focus and camera position steady. Use an exposure that limits motion blur, and avoid saturated areas where neighboring strokes merge. For sequentially exposed sensor rows, moving material can introduce geometric distortion even when individual edges appear sharp.

Automatic brightness changes can move segmentation boundaries. If automatic exposure is necessary, measure brightness from a stable region rather than from whichever cells the detector currently finds. The guide to auto exposure ROI instability explains that feedback problem.

For an illustrative sampling calculation, suppose the inspection width is 160 mm and the smallest feature relevant to center detection is 0.4 mm. An initial target of 8 pixels across that feature gives:

Required image width = field width × target pixels / feature width Required image width = 160 mm × 8 pixels / 0.4 mm Required image width = 3200 pixels Object sampling = 160 mm / 3200 pixels Object sampling = 0.05 mm/pixel

Eight pixels is a starting assumption for this example, not a universal detection requirement. A narrower break used for shape inspection may require finer sampling than the overall cell used for occupancy.

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

Compare candidate area scan cameras through the camera finder. Validate sampling with representative images rather than selecting by total pixel count alone. For tolerances expressed in physical units, establish scale and distortion using camera calibration for length measurement.

3. Register an anchored reference lattice

  1. Describe the expected cell locations with an origin and two repeat vectors, then register that model to each image.

For a flat, regular pattern, an affine lattice is a useful starting point:

Expected position(i, j) = origin + i × u + j × v i, j = integer column and row indices u, v = repeat vectors expressed in image pixels

The vectors need not be perpendicular. Their lengths describe the observed spacing, while their directions describe the pattern orientation and skew.

Establish the reference from an approved sample or known geometry. Register each production image using stable landmarks, the material boundary, or a distributed set of reliable cells. Use a transform appropriate to the imaging geometry. Perspective viewing of a planar surface may require projective registration rather than an affine adjustment.

Repeated patterns create a particular risk: moving the lattice by one complete pitch can still produce a convincing alignment. Anchor the indexing to a distinctive feature or a known boundary. Without that anchor, the system might count cells correctly while reporting the wrong row and column.

Reject registration when its residuals, scale change or visible support exceed validated limits. Do not fit an independent correction around every suspect site; that can move an expected position onto an unrelated detection and conceal a defect.

4. Extract one reliable center per cell

  1. Detect candidate cells and calculate a consistent representative center for each candidate.

Choose the method around the pattern geometry. Connected components may work when cells are clearly separated. Enclosed openings may provide more stable centers than variable-width outlines. A shape detector can help when thresholding fragments a single cell into several pieces.

The center must represent the same feature throughout the inspection. Mixing an opening centroid with an outer-boundary centroid can introduce systematic offsets on asymmetric cells.

Use preprocessing conservatively:

  • Correct gradual background variation without erasing the smallest relevant feature.
  • Select polarity explicitly so that foreground and background do not exchange roles.
  • Reject obvious debris using broad size and geometry limits.
  • Merge duplicate detections only when their image evidence supports the same cell.
  • Preserve intermediate masks and center overlays for diagnosis.

The live binary image preview guide is useful when a threshold or morphology operation changes which cells survive extraction.

A thick connecting stroke may merge neighboring cells into one component. Conversely, a broken stroke may split a cell into several components. Neither event should automatically become a missing-cell result. Inspect representative thick, thin, broken and touching examples before deciding that component centroids are suitable.

5. Match centers within a measured tolerance

  1. Assign candidate centers to expected positions using a distance gate and a one-to-one matching rule.

For each expected position, calculate distances to nearby candidate centers. Permit a pairing only when its distance is within the accepted positional tolerance. Each candidate can occupy at most one site, and each site can accept at most one candidate.

A gated minimum-cost assignment is useful where several pairings compete. Independent nearest-neighbor searches can incorrectly reuse a candidate for multiple sites. If you use a simpler greedy matcher, test its behavior around clustered detections and neighboring empty sites.

Choose the gate from measured variation, not from whichever value makes a demonstration image pass. A conservative error budget can add estimated bounds:

Position gate ≥ registration error + center error + allowed cell displacement Example budget = 0.04 mm + 0.06 mm + 0.03 mm Example budget = 0.13 mm Trial gate = 0.15 mm Gate in pixels = 0.15 mm / 0.05 mm per pixel Gate in pixels = 3 pixels

These illustrative bounds must be replaced with measurements from acceptable production samples. The sum assumes conservative bounds rather than a statistical combination of independent errors.

Suppose neighboring sites are 2 mm apart. At the example sampling, their spacing is 2 / 0.05 = 40 pixels. A gate smaller than half the nearest-site spacing avoids overlapping circular acceptance regions for an ideal lattice. That geometric check does not prove the detector or registration is reliable.

6. Turn unmatched sites into inspection results

  1. Classify unmatched positions only after checking visibility and image quality, then apply shape checks to occupied sites.

Consider an inspection region containing 12 columns and 8 rows, with all expected cells fully visible:

Expected sites = 12 × 8 = 96 Detected candidate centers = 94 Accepted one-to-one assignments = 92 Unmatched expected sites = 96 − 92 = 4 Unassigned candidate centers = 94 − 92 = 2

The initial result is four unmatched sites, not necessarily four confirmed missing cells. Suppose two sites clearly show exposed background, one has inadequate contrast, and one is obscured. The report should distinguish two missing cells from two uninspectable positions. The two extra candidates remain available for debris or duplicate-detection diagnostics.

Next, inspect the 92 occupied sites for malformed geometry. A cell with a broken border may still produce an acceptable center. Record occupancy and shape as separate fields so the same cell can be present but malformed.

Exclude partially visible boundary cells unless the inspection explicitly supports them. Define that exclusion in reference coordinates with enough margin for normal registration movement. Otherwise, cells entering and leaving the image edge will produce changing counts unrelated to product quality.

Store the expected index, measured center, assignment distance and classification. An overlay should show the expected position and observed center separately, with a connecting line for accepted matches. This makes incorrect associations easier to diagnose than a single pass/fail marker.

7. Verify performance with controlled defects

  1. Validate the complete pipeline using labeled images that separate missing cells, malformed cells and acquisition failures.

Build a test set covering normal positional variation, thickness variation, contrast changes and boundary positions. Include missing adjacent cells, not just isolated gaps. Add examples with debris near empty sites because these challenge the assignment rule directly.

Report different error types separately:

  • Missing cells incorrectly accepted as occupied.
  • Good cells incorrectly reported as missing.
  • Malformed cells accepted by the shape check.
  • Invalid images allowed to produce an ordinary pass.
  • Incorrect row or column indexing after registration.

For example, zero missed defects in 100 labeled defective sites describes that test set; it does not establish a universal failure probability. Keep parameter-tuning images separate from the final evaluation images, and document which product variants each recipe covers.

Record processing time for registration, candidate extraction, assignment and shape analysis separately. An acceptable average can hide occasional slow images that miss the machine's decision deadline. Define how the control system handles late results and uninspectable images before production release.

Choose hardware around the inspection workload

The algorithm requires access to the image and enough processing capability for registration, center extraction, assignment and diagnostics. Hardware selection should follow a working image-based prototype.

The LS-CMR-0166 is a USB3 area scan camera with a rolling shutter. Check its acquisition behavior against material motion and the intended trigger sequence.

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

The LS-SMC-0063 is a smart camera with a GigE interface. Its catalog description does not establish support for lattice registration or one-to-one assignment; confirm the required tools, data access and recipe behavior before selecting it.

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

Compare smart cameras when on-device execution is desirable, but treat algorithm availability as a separate acceptance test. Consider vision controllers when the processing needs a dedicated machine-vision platform. Confirm software compatibility and application timing rather than inferring performance from an interface label.

Use the camera configuration starting point after defining sampling, exposure, trigger behavior and processing architecture.

Build the whole station

The configurator matches a camera, lens, light, light controller and cables to each other, step by step, and lists only parts that fit what you already picked.

Start with the camera

Limits and checks before ordering

Lattice matching is not the right primary method when the pattern has no stable repeat structure. Strong local stretching, folds or changing perspective can also invalidate a single global lattice. A constrained local model may help, but excessive flexibility can explain away the very defects you need to detect.

Occupancy alone cannot prove continuity or detect every narrow break. If the requirement concerns broken connections, add topology or continuity checks at adequate sampling. If adjacent valid cells merge unpredictably, reconsider the center detector before changing assignment thresholds.

Before committing to hardware or acceptance limits, complete this checklist:

  • Confirm the inspection distinguishes missing, malformed and uninspectable cells.
  • Define the indexed region and its treatment of partial boundary cells.
  • Demonstrate registration without whole-pitch indexing errors.
  • Measure acceptable center variation and registration residuals separately.
  • Validate one-to-one assignment with neighboring gaps and nearby debris.
  • Verify that required shape defects remain visible at the chosen sampling.
  • Save images, intermediate detections and final classifications for diagnosis.
  • Test recovery after startup, recipe changes and interrupted acquisition.

For an application review, use technical support with representative acceptable and defective images, the field width, smallest relevant feature, material speed and required decision time. Those inputs make it possible to assess the imaging setup and matching strategy together.

Questions

Why use cell centers instead of a reference difference image?

Pixel subtraction responds to brightness and boundary changes, even when the intended cell remains present. Position-based occupancy checks tolerate some of that variation because they compare representative centers. They still depend on repeatable imaging and reliable candidate extraction, so they are not a substitute for controlling contrast and blur.

How should the positional matching tolerance be chosen?

Measure registration residuals and center-location variation across acceptable samples, including normal product movement and thickness changes. Choose a gate that accommodates those validated variations without allowing neighboring sites to compete. If the required gate approaches the cell spacing, improve the imaging or registration rather than accepting ambiguous matches.

Can lattice matching detect broken or malformed cells?

Not reliably by itself. A damaged cell may retain a center close to its expected position and therefore pass occupancy matching. Add a separate inspection of continuity, shape or critical dimensions, and confirm that the smallest required defect remains visible at the selected image sampling.

Can this inspection run entirely on a smart camera?

Use an on-device implementation only after confirming the required registration, candidate extraction, assignment and reporting capabilities. A catalog interface or resolution specification does not establish algorithm support. Prototype the complete inspection and measure its timing before deciding where the processing should run.