请输入
菜单

Image Alignment User Guide

作者: JT下载

Image Alignment User Guide

Applicable software: FIX Inspection Software
Document version: 2026-04-20


1. Why Image Alignment Is Needed

In real-world inspection, products from the same batch never image at exactly the same position. The reasons include:

  • Mechanical positioning error: conveyors, trays, and fixtures all carry millimeter-level tolerance.
  • Manual placement bias: operators place products with slight translation and rotation (typical 0° / 90° / 180° / 270° orientations).
  • X-ray geometry variation: minor changes in rotary-stage angle, tilt, and magnification introduce scale differences.
  • Minor posture differences within the product itself: warping and uneven thickness cause projection distortion.

The inspection ROIs, inspection rules, and reference templates drawn during Teaching are all anchored to that single teaching image's coordinate system. If the incoming image is not first "moved back" to the teaching pose, every downstream ROI will land on the wrong location, and the inspection result will inevitably be off.

One-sentence definition: Image Alignment = transform the current product image by translation, rotation, and (when necessary) scaling into the same coordinate system as the teaching template, then copy the inspection ROIs from the template into the image and run inspection on them.


2. Position in the Processing Chain

A FIX processing chain is a series of modules executed in order. A typical configuration for void inspection looks like this:

复制代码
  ┌──────────────────┐
  │  Original Image  │   ← incoming X-ray image
  └────────┬─────────┘
           │
           ▼
  ┌──────────────────┐
  │ Image Alignment  │   ← this module (must come before inspection)
  └────────┬─────────┘
           │  Output: aligned image + transform matrix
           ▼
  ┌──────────────────┐
  │ Void Inspection  │   ← inspection module uses teaching ROIs
  └──────────────────┘

Key rules:

  • The alignment module must sit before every inspection module that uses ROIs / teaching coordinates.
  • When alignment fails, downstream inspections are flagged with an alignment error, and the current result is invalid.

3. Teaching and Runtime Workflow

3.1 Teaching phase

  1. Open a typical, representative sample image (correct pose, defect-free is recommended).
  2. Place the inspection ROIs and finish the inspection setup (parameters, rules, thresholds, etc.).
  3. The Image Alignment module is automatically inserted before the inspection module, and the current sample image is automatically saved as the reference image. No manual configuration is required.
  4. If necessary, adjust the alignment mode inside the Image Alignment module to suit the product (full-image / ROI image alignment / threshold alignment / model alignment — see Sections 4 and 5).
  5. Save the teaching file — all module parameters (reference image, inspection ROIs, thresholds, model paths) are persisted together.

📌 The teaching image is critical: it should be clean, defect-free, and in the standard reference pose. Once the teaching file is released, this reference image is baked into the teaching file, and every future product will be aligned against it.

3.2 Runtime phase

  1. Load the teaching file — the processing chain is rebuilt in the taught order.
  2. The incoming image is fed into the chain.
  3. The Image Alignment module reads the reference → computes the transform matrix → outputs the aligned image.
  4. Downstream modules run inspection on the aligned image, and the ROIs naturally land in place.

4. Alignment Algorithm Overview

FIX provides 4 alignment strategies, listed from highest to lowest recommendation priority:

Priority Method When to use Speed
① First choice Default full-image alignment (template matching + automatic rotation detection) The vast majority of standard scenarios: product pose is generally consistent, the image is reasonably clean. Works out of the box with no extra configuration. ★★★★
② Second choice ROI image alignment: draw a rectangular ROI and tick "Set As Image Alignment ROI" Use when the image edges or parts of the frame have strong distractors (silkscreen, tooling holes, tray, other components) and you want the algorithm to focus on the product body / center. ★★★★
③ Special case Threshold Alignment Only for special materials: no fixture, very clean background (e.g. a pure white tray), with randomly hand-placed small items on top, and very strong grayscale contrast between product and background. Not recommended for general use. Whether to enable it in a specific project must follow the project instructions issued by the FIX team. ★★★★★
④ Fallback Alignment Models (advanced, model-based) When none of the three methods above yields stable results, contact the FIX team to train a product-specific alignment model. Typical examples: soft / flexible materials, thin films, products that cannot be fully flattened — generic methods usually align poorly, and model alignment must be used as a fallback. ★★

📌 Always try in the order ① → ② → ③ / ④. If neither ① nor ② is stable, first check the FIX project instructions to decide whether ③ applies. If that still fails, contact the FIX team to evaluate ④.


5. UI Parameter Reference

The Image Alignment panel is split into four groups from top to bottom: Selected ROI, Image Alignment Settings, Alignment Models, Threshold Alignment.

5.1 Selected ROI

When you select an ROI on the canvas, the switches below apply to that ROI.

Control Effect
Set As Image Alignment ROI Marks the current ROI as the "alignment reference region". The algorithm does template matching only within this region instead of over the full image. Suited for products that carry distinctive internal features (locating holes, characters, pad arrays) but have noisy edges or cluttered background. Once set, the ROI is drawn with a yellow border.
Set as Dynamic ROI Enables "runtime adaptive tracking" for the ROI. Even if the global alignment is not perfectly accurate, the ROI will re-match itself onto the target by a local template match on the aligned image. Suited for scenarios where a single small component (QFN, tiny chip, locating pin) has an independent positional offset.

Dynamic ROI sub-parameters

Control Default Range Description
Alignment Score > 90 0–100 Minimum confidence (%) for dynamic tracking. Below this value the tracker considers "not found" and the ROI does not move. Higher = stricter, lower = more permissive.
Current Score read-only Actual match score from the last run — useful for tuning the threshold.
Search Padding (px) 100 0–9999 How many pixels to expand around the ROI as the search window. The larger the potential offset, the larger this must be; but too large noticeably slows things down. Rule of thumb: expected maximum offset + 30% margin.
Move Child ROI checked When checked, all child ROIs under this ROI follow the parent as a rigid group, preserving their relative positions.
Reference Bounding Box Bounding Box / Center Whether child ROIs follow the parent by its bounding-box corners or its center point. Usually leave as default.

5.2 Image Alignment Settings

Controls full-image alignment (the default template-matching mode).

Control Default Description
Alignment Score < 1500 Failure threshold for full-image alignment (template-matching score). If the best score is below this value, alignment is considered a failure. Larger = stricter. Increase when incoming material is stable; decrease when pose varies a lot.
Current Score Read-only. Shows the actual score from this run.
SSIM Score Read-only, 0–1. 1 means the aligned image is structurally identical to the reference. A direct quality indicator for the alignment.
Disable Image Alignment unchecked Master switch. When checked, the module becomes a pass-through and applies no transform. Use only for debugging or when the product is fully fixtured with zero offset.
Disable Auto Rotation unchecked Disables automatic 90° / 180° / 270° rotation detection. Check when the incoming pose is known to be fixed — speeds things up and prevents mis-detection.
Disable Object Finding Before Alignment unchecked Skips the "first find the product outline, then align" pre-step and matches directly over the full image. When the product sits at a fixed position and the background is clean, checking this speeds things up. If the background is complex, leave it unchecked.
Show Alignment Score unchecked Overlays the alignment score / SSIM on the output image for debugging. Recommend unchecking during production.
Use Structure Alignment unchecked Experimental. Uses structure-based (edge / gradient) alignment, which is sometimes more robust on low-contrast scenes. Only enable when the default method is not performing well.
Use Affine Alignment unchecked The default is a rigid transform (translation + rotation + uniform scale). When checked, a 6-DOF affine transform is allowed (adding shear and non-uniform scale). Suited for products with slight deformation (flex PCBs, thermal expansion / contraction), but more sensitive to noise — do not enable without a reason.
Use Enhanced Rotation Detection unchecked Upgrades rotation detection from "pure template matching" to keypoint matching. More robust on products with distinct features (characters, leads, pad arrays). On featureless flat surfaces it can be worse than the default.
Reference Image Path Full disk path of the reference (template) image. Usually browsed via the button on the right. The path is saved in the teaching file; when deploying to another machine, make sure the path is valid. Recommend using a relative path to the teaching file, or a fixed shared path.

5.3 Alignment Models (advanced, model-based alignment)

When a product has special characteristics and the generic image-alignment functions (template matching / threshold alignment) do not perform well, switch to "advanced model alignment" — a product-specific alignment model trained and delivered by the FIX team.

Typical situations that call for model alignment:

  • Large appearance variation in incoming material (color, surface finish, batch-to-batch differences cause template-matching scores to be consistently low);
  • Complex background, or the product occupies only a small portion of the frame (open trays, loose-piece handling, mixed products);
  • 2D → 3D deformation or occlusion (warping, tilting, partial occlusion by the fixture);
  • Parameter tuning does not produce stable alignment — field tests show template-matching failure rate above 5%.
Control Description
Model drop-down Selects an alignment model provided by the FIX team. Selecting "None" disables model alignment and the default template matching is used.
Test Runs the selected model once on the current image and overlays the detected target with a cyan rectangle, so you can confirm the model identifies the correct target.

📌 If your on-site product needs model alignment, contact the FIX team: provide several representative incoming images and one teaching template image, and we will train a product-specific model and deliver a model file. Drop it into the designated folder and it will appear in the drop-down.

5.4 Threshold Alignment

This is a checkable group — checking the group title enables threshold alignment mode, which overrides the default template matching.

Control Default Range Description
Threshold (slider) 128 0–255 Binarization threshold. The numeric value is shown on the right as you drag. In X-ray grayscale images the product is usually darker / brighter than the background, and the threshold is chosen between the two.
Invert unchecked Inverts the binarization direction. Default: "below threshold = foreground". When checked: "above threshold = foreground". Choose based on whether the product is darker or brighter than the background.
Min Area 200 0–999999 Contours with fewer pixels than this are filtered out, preventing edge noise from corrupting the centroid calculation. Reduce for small parts, increase to filter smudges on large ones.
Rotation Detection (180°) unchecked Adds a 180°-pose check on top of threshold alignment. Suited for products that may be placed upside down.

Principle: apply the same binarization to reference and current images → filter contours → compute the foreground centroid → translate the current image so its centroid matches the reference centroid. Only translation is handled (plus an optional 180° flip); rotation and scale are not.

When to use:

  • The product only has translational offset (fixture is accurate, only a few millimeters of drift);
  • Product-vs-background grayscale contrast is very clear (gaskets, small chips, stand-alone parts);
  • Extreme speed is required — threshold alignment is 3–5× faster than template matching.

6. Alignment Flow in Detail — How the Matching Score Is Computed

This section explains the full computation for the default mode (template matching). Understanding it helps in setting the "Alignment Score <" threshold sensibly.

6.1 Overall steps

复制代码
 ┌─────────────────────┐   ┌─────────────────────┐
 │   Reference image   │   │   Current image     │
 │   (saved at teach)  │   │   (incoming)        │
 └──────────┬──────────┘   └──────────┬──────────┘
            │                         │
            └───────────┬─────────────┘
                        ▼
              ┌──────────────────────┐
              │ Step ① Size match    │
              │ Sizes differ?        │
              │ Pad / crop current   │
              │ to reference size    │
              └──────────┬───────────┘
                         ▼
              ┌──────────────────────────┐
              │ Step ② Object finding    │ ← can be skipped via
              │ Use contour/threshold    │   "Disable Object Finding
              │ to find product bbox     │    Before Alignment"
              └──────────┬───────────────┘
                         ▼
              ┌──────────────────────────┐
              │ Step ③ Rotation detect   │ ← can be skipped via
              │ 90° / 180° / 270° ?      │   "Disable Auto Rotation"
              │ If yes, rotate back      │
              └──────────┬───────────────┘
                         ▼
              ┌──────────────────────┐
              │ Step ④ Template      │ ★ score is produced here
              │ matching:            │
              │ slide template over  │
              │ current, compute     │
              │ per-pixel similarity │
              └──────────┬───────────┘
                         ▼
              ┌──────────────────────┐
              │ Step ⑤ Transform     │
              │ From the best match  │
              │ position, derive the │
              │ 2×3 translation /    │
              │ scale / rotation mat │
              └──────────┬───────────┘
                         ▼
              ┌──────────────────────┐
              │ Step ⑥ Resample      │
              │ Warp current with    │
              │ the transform →      │
              │ aligned output image │
              └──────────┬───────────┘
                         ▼
              ┌──────────────────────┐
              │ Step ⑦ Score evals   │
              │ • Alignment Score    │
              │ • SSIM Score         │
              │ Below threshold →    │
              │ failure              │
              └──────────────────────┘

6.2 How the template-matching score is computed (Step ④ detail)

Template matching uses normalized cross-correlation. The reference image becomes a "template" that is slid over the current image, position by position, and compared:

复制代码
Current image (search area)
 ┌──────────────────────────────┐
 │                              │
 │    ┌──────┐                  │
 │    │tmpl  │←── compare pixel │
 │    │      │    similarity    │
 │    └──────┘    at this spot  │
 │         ┌──────┐             │
 │         │tmpl  │←── next     │
 │         └──────┘    position │
 │              ...             │
 └──────────────────────────────┘
        ↓
  Every position yields a score
        ↓
  Position of the highest score
         = best match

The score at each position = the normalized correlation coefficient between the template pixels and the search-image pixels at that position, in the range −1 ~ +1 (mapped inside the software to an integer in the range 0–99999 depending on implementation):

Correlation Meaning
Near +1 Pixel patterns are highly consistent — perfect match
Near 0 No correlation — essentially no match
Near −1 Anti-correlated (rarely seen)

Alignment Score = the highest score found across the image.

  • Default threshold 1500 (corresponds to a fairly good correlation).
  • Only when "highest score ≥ threshold" is alignment considered successful.

SSIM Score is computed after alignment, between the aligned image and the reference image (0–1):

  • ≥ 0.85: excellent alignment quality;
  • 0.60 ~ 0.85: acceptable;
  • < 0.60: structures are clearly off — adjust parameters.

6.3 Rotation detection flow

复制代码
 Reference + Current
        │
        ▼
 ┌────────────────────────┐
 │ "Use Enhanced Rotation │
 │  Detection" checked?   │
 └────┬───────────┬───────┘
      │ Yes       │ No
      ▼           ▼
 ┌─────────┐   ┌───────────────┐
 │Keypoint │   │ Rotate current│
 │extract  │   │ by 0° / 90° / │
 │& match  │   │ 180° / 270°   │
 │→ angle  │   │ and run       │
 └────┬────┘   │ template match│
      │        │ on each;      │
      │        │ pick best     │
      │        └──────┬────────┘
      └────────┬──────┘
               ▼
   Determined product rotation
               ▼
     Rotate current back to 0°
               ▼
       Proceed to Step ④

6.4 Dynamic ROI secondary fine-alignment

After global alignment lands the whole product, individual small components (QFNs, single capacitors, locating pins) may still carry residual offset. For ROIs ticked as "Set as Dynamic ROI", the algorithm performs a second local tracking on top of the global alignment:

复制代码
  Global alignment done (body landed)
                │
                ▼
  ┌────────────────────────────────┐
  │ For each Dynamic ROI:           │
  │                                 │
  │  ① Center on the taught ROI     │
  │  ② Expand outward by            │
  │     "Search Padding" pixels     │
  │  ③ Run template match again     │
  │     inside the expanded area    │
  │  ④ Best score ≥ threshold?      │
  │      Yes → move the ROI to the  │
  │            best match location  │
  │      No  → keep original spot,  │
  │            write score to UI    │
  │  ⑤ If "Move Child ROI" is       │
  │     checked, children follow    │
  │     the parent as a group       │
  └────────────────────────────────┘

7. Choosing an Alignment Method

Scenario Recommended Key parameters
Standard PCB / general material, pose mostly consistent ① Default full-image alignment Keep "Alignment Score < 1500" default
Noisy frame edges, want to focus on the product center ② ROI image alignment — draw a rectangle + tick "Set As Image Alignment ROI" ROI should be slightly larger than the key features, but not cover the whole image
Product may be rotated (0° / 90° / 180° / 270°) Leave "Disable Auto Rotation" unchecked; enable "Use Enhanced Rotation Detection" when features are distinct
Flex PCB, thermal deformation, slight geometric distortion Enable "Use Affine Alignment" Lower the alignment-score threshold a bit
No fixture / pure-white background / randomly hand-placed small items ③ Threshold Alignment (special case, enable per project instructions) Tune "Threshold" and "Min Area"
None of the generic methods is stable (soft materials, cannot be flattened, etc.) ④ Contact the FIX team to train a product-specific model After delivery, verify with the "Test" button
A few small components on a single board drift independently Enable "Set as Dynamic ROI" on those ROIs "Alignment Score > 90", "Search Padding" = max offset + margin

8. Troubleshooting

Error message Meaning Suggestion
Image Alignment Failed: Input Image is Empty Input image not loaded Check upstream module and image source
Image Alignment Failed: Reference Image is Empty / Invalid Reference path invalid Re-specify the Reference Image Path
Image Alignment Failed: No Object Found Match score is below threshold Lower "Alignment Score <"; or try ROI alignment; or contact the FIX team for model alignment
Image Alignment Failed: Template rect is invalid The alignment ROI is outside the image Check the ROI position; check that reference and current image sizes agree
Threshold Alignment: No object found in reference image Threshold too high / low, or Min Area too large Adjust the threshold slider, try "Invert", reduce "Min Area"
Threshold Alignment: No object found in current image Brightness / contrast of the current image differs from teaching Check that X-ray exposure parameters match, or switch to a different alignment mode

Debugging tips

  1. Check "Show Alignment Score" to observe the actual score and judge if the threshold is reasonable.
  2. Watch the SSIM Score: ≥ 0.85 = excellent alignment; 0.60–0.85 = acceptable; < 0.60 = reconsider parameters.
  3. The module preview window shows "current | reference | aligned" side by side — visual inspection already tells you the alignment quality.
  4. When using model alignment, press the "Test" button first to confirm the detection box is correct, then release to production.

9. Performance and Deployment Notes

  • Threshold Alignment is the fastest (millisecond-level), template matching is next, model alignment is the slowest but the most robust.
  • The GPU edition of FIX automatically accelerates model alignment and parts of template matching.
  • The reference image path stored in the teaching file must be kept in sync when deploying to another machine. Recommend placing the reference image and the teaching file in the same relative directory, or on a shared network path.

最近修改: 2026-04-20Powered by