Applicable software: FIX Inspection Software
Document version: 2026-04-20
In real-world inspection, products from the same batch never image at exactly the same position. The reasons include:
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.
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 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.
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 ④.
The Image Alignment panel is split into four groups from top to bottom: Selected ROI, Image Alignment Settings, Alignment Models, Threshold Alignment.
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. |
| 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. |
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. |
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:
| 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.
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:
This section explains the full computation for the default mode (template matching). Understanding it helps in setting the "Alignment Score <" threshold sensibly.
┌─────────────────────┐ ┌─────────────────────┐
│ 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 │
└──────────────────────┘
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.
SSIM Score is computed after alignment, between the aligned image and the reference image (0–1):
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 ④
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 │
└────────────────────────────────┘
| 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 |
| 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 |