System designHow-to

Three image stitching with a shared coordinate frame

Make three image stitching reliable with adjacent-image registration, a shared coordinate frame, canvas calculations, match checks, and overlap blending.

LumaSpec Vision10 min read Share on LinkedIn

On this page 9 sections
  1. 011. Choose the geometric model and prepare the inputs
  2. 022. Register adjacent original images
  3. 033. Express every transform in the middle frame
  4. 044. Calculate a canvas that contains all three views
  5. 055. Warp each original once and blend valid overlap
  6. 066. Work through a numerical example
  7. 077. Verify alignment and recognize model failure
  8. 088. Select acquisition parts and record the configuration
  9. 09Questions

Three overlapping images should become one mosaic through a shared coordinate frame, not through another round of stitching already blended pairs. Pairwise composites introduce canvas offsets, duplicated content, and interpolation changes that make the next registration harder to diagnose. This workflow is for engineers building inspection mosaics from adjacent views. You will register the original images, express their transforms relative to the middle image, and render them onto one canvas with explicit validity masks.

1. Choose the geometric model and prepare the inputs

Keep the three original images unchanged. Label them A, B, and C in viewing order, with overlap between A–B and B–C. A and C do not need to overlap if both adjacent registrations are reliable.

A homography describes a projective mapping between two image planes. It is suitable for a flat inspected surface, or for an ideal pinhole camera rotating around its projection center. It is not a general solution for translated views of objects at different depths.

Approach Appropriate use Main limitation
Translation Views differ only by horizontal and vertical displacement Cannot correct rotation, scale, or perspective
Affine transform Perspective differences are negligible over the inspected region Cannot represent general projective distortion
Homography A planar surface viewed from different poses Cannot align multiple depths under translation
Depth-aware registration Surface depth changes and viewpoint translation matter Requires additional geometry and visibility handling

Use the simplest model that explains the geometry. An unnecessarily flexible model can fit incorrect matches while producing plausible-looking overlap.

Prepare the acquisition before adjusting matching parameters:

  1. Keep focus, aperture, exposure, and gain fixed where practical.
  2. Capture a static scene, or coordinate acquisition so that moving content does not change between views.
  3. Retain original dimensions, pixel formats, and any existing calibration information.
  4. Inspect overlap for texture, saturation, blur, and repeated patterns.

For a planar target, the guidance on calibration target flatness helps distinguish surface geometry errors from registration errors.

2. Register adjacent original images

Detect and describe features in A, B, and C. Matching can use grayscale representations, while the final mosaic can retain the original color information.

Match A against B, then C against B. Both estimated transforms should therefore map toward B. Reject ambiguous descriptor matches and use a robust estimator to separate consistent correspondences from outliers.

A homography needs at least four point correspondences in general position. That mathematical minimum is not a practical acceptance criterion. Additional correspondences spread across the overlap provide evidence that the mapping describes the surface rather than one small textured patch.

Validate each adjacent registration before building the canvas:

  • Check the number and fraction of inliers, not just the total match count.
  • Plot inlier locations and look for broad spatial coverage.
  • Measure reprojection residuals, including their upper percentiles.
  • Inspect transformed corners for extreme stretching, folding, or implausible orientation.
  • Compare edges or landmarks that were not used to estimate the transform.

As an initial diagnostic setting, a reprojection threshold of 2 pixels may be reasonable for sharp, full-resolution images. It is not a universal tolerance. Feature localization, image scale, distortion, and the inspection requirement determine the acceptable value.

Repeated holes, printed grids, or similar package edges can produce many mutually consistent but incorrect matches. Restrict matching to the expected overlap and check independent landmarks before accepting the estimate.

3. Express every transform in the middle frame

Declare the transform convention explicitly. The following equations use homogeneous column vectors, with each matrix mapping source coordinates to destination coordinates.

p_B ~ H_AB × p_A p_B ~ H_CB × p_C G_A = H_AB G_B = I G_C = H_CB

Here, the symbol ~ means equality up to a nonzero scale. Divide the first and second transformed components by the third component to recover ordinary image coordinates.

If your registration routine instead estimates a mapping from B to C, invert that matrix before using it as the C-to-B transform:

H_CB = inverse(H_BC)

Do not transpose a matrix to reverse its direction. A transpose and an inverse are different operations.

The middle image is a useful reference because it avoids introducing an additional transform chain for this three-view arrangement. It does not remove uncertainty in either adjacent estimate.

Independently stitched pairs have their own coordinate systems. Their renderers may add translations, crop borders, resize output, or blend duplicate copies of B. A second stitching pass must then recover geometry from those modified images. Keeping the original images and their transforms avoids that extra ambiguity.

4. Calculate a canvas that contains all three views

Transform the corners of each original image using its corresponding G matrix. For pixel-center coordinates, the corners of an image with width W and height H are:

(0, 0), (W - 1, 0), (W - 1, H - 1), (0, H - 1)

Collect the transformed corners from all three images. Calculate integer bounds that include them:

x0 = floor(minimum transformed x) y0 = floor(minimum transformed y) x1 = ceil(maximum transformed x) y1 = ceil(maximum transformed y) canvas width = x1 - x0 + 1 canvas height = y1 - y0 + 1

Negative coordinates are normal when A extends to the left of B. Add a translation that moves the minimum canvas coordinates to zero:

T = [[1, 0, -x0], [0, 1, -y0], [0, 0, 1]] M_A = T × G_A M_B = T × G_B M_C = T × G_C

These M matrices map each original into the final canvas.

Check the homogeneous denominator over each image domain before accepting its bounds. If the mapping approaches or crosses a projective singularity, corner-based bounds can become enormous or meaningless. Reject that estimate rather than allocating the requested image.

Apply a configurable limit to canvas dimensions and memory consumption. An unexpectedly large canvas usually indicates a bad transform or reversed mapping, not a legitimate need for more memory.

If missing borders occur after an earlier geometric correction, investigate black borders after undistortion before changing the stitching geometry.

5. Warp each original once and blend valid overlap

Render A, B, and C directly into the final canvas. Do not warp A into B, render that pair, and then warp the rendered pair again.

Most raster warping operations sample destination pixels by mapping them back into the source. Some interfaces accept a forward matrix and invert it internally; others expect the inverse explicitly. Confirm the documented convention and check a known point to avoid applying the inverse twice.

If lens correction is required, compose its sampling map with the projective mapping where supported. The goal is one final interpolation from each original, rather than several consecutive image resampling operations.

The related guide on antialiasing during downsampling and warping explains filter selection. Here, the key distinction is geometric: establish the final mapping before rendering.

Warp a validity mask alongside each image. A black intensity value is valid scene content, so it must not be treated as evidence that a pixel lies outside the source image. Use a separate mask and define how interpolation support near source borders affects validity.

For a simple feathered blend, give valid pixels larger weights away from their source boundaries:

output(x, y) = sum[w_i(x, y) × warped_i(x, y)] / sum[w_i(x, y)]

Set each weight to zero outside its valid support. Leave the output invalid wherever the total weight is zero.

Feathering reduces visible brightness transitions, but it cannot correct geometric misalignment. Double edges usually require better registration, a different model, or a seam that avoids the affected object.

For dimensional inspection, preserve the original warped views and their masks as well as the blended display. A visually smooth seam is not proof that measurements across that seam are accurate.

6. Work through a numerical example

Consider three hypothetical images, each 1600 × 1200 pixels. Assume a flat surface, equal scale, no rotation, and horizontal displacement only.

Suppose A maps into B with a horizontal translation of −1200 pixels, while C maps into B with +1200 pixels. Each adjacent pair overlaps by:

overlap = 1600 - 1200 = 400 pixels overlap fraction = 400 / 1600 = 25%

This overlap is an example, not a guaranteed minimum. Texture and viewpoint determine whether it supplies enough reliable correspondences.

In B coordinates, the horizontal extents are:

  • A: −1200 through 399.
  • B: 0 through 1599.
  • C: 1200 through 2799.

The shared canvas therefore has:

width = 2799 - (-1200) + 1 = 4000 pixels height = 1200 pixels canvas translation = +1200 pixels horizontally

After the canvas translation, the left edges of A, B, and C land at 0, 1200, and 2400 pixels respectively. These positions provide an easy test case for transform direction and multiplication order.

A floating-point color accumulator with three channels and four bytes per channel would occupy:

4000 × 1200 × 3 × 4 = 57,600,000 bytes

That is 57.6 MB in decimal units for the accumulator alone. Source images, warped layers, masks, weights, and temporary buffers add to the allocation.

Now suppose the rectified mosaic covers a planar width of 200 mm. Its nominal sampling is:

object sampling = 200 mm / 4000 pixels = 0.05 mm/pixel samples across a 0.25 mm feature = 0.25 / 0.05 = 5 pixels

If the design target is four samples across that feature, the required mosaic width is:

required pixels = (200 mm / 0.25 mm) × 4 = 3200 pixels

The camera resolution guidance explains why sample count alone does not establish measurement accuracy. This arithmetic assumes a rectified planar output with uniform scale; an arbitrary projective mosaic does not provide that automatically.

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

7. Verify alignment and recognize model failure

Inspect the mosaic at full output resolution, not only as a reduced preview. Downsampling can hide doubled edges and local registration errors.

Use this acceptance checklist:

  • Confirm that every original appears once, with no duplicated middle view.
  • Check independent landmarks across both overlaps, including their edges.
  • Compare residuals against the inspection tolerance in the same coordinate units.
  • Inspect validity masks for holes and unintended clipping.
  • Repeat acquisition to measure registration stability, not just one favorable capture.
  • Test the least textured and most reflective expected parts.
  • Retain transforms, calibration identifiers, and quality metrics with each output.

Parallax often appears as one depth aligning while another remains displaced. For example, a flat background may register correctly while raised components show doubled boundaries. Increasing the homography's inlier threshold only hides evidence of the mismatch.

Possible remedies include reducing viewpoint translation, inspecting a single plane, using depth-aware geometry, or changing the acquisition arrangement. Local warps can improve appearance, but they may also deform dimensions and should not be accepted as metrology corrections without validation.

Moving objects create a different failure: no static transform can place an object consistently if it changed position between captures. Address acquisition timing before changing the blending method.

8. Select acquisition parts and record the configuration

Stitching quality begins with repeatable source images. Use the area scan cameras category and camera finder to narrow interface, shutter, and resolution requirements before selecting a device.

The LS-CMR-0053 is a GigE area scan camera with a C-mount. Treat it as an acquisition candidate, not a claim that stitching performance is predetermined by the camera.

Area scan cameras12 MP GigE area scan camera, IMX226, 1/1.7" rolling shutter, 9 fps (LS-CMR-0053)LS-CMR-0053
Sensor format
1/1.7"
Lens mount
C-mount
Interface
GigE
Resolution
12 MP
$560.00View partBuild a system with it

Review machine vision lenses through the lens finder. Check sensor coverage, mount, working distance, distortion, and sharpness across the overlap rather than judging only the image center.

The LS-FFL-0567 is a C-mount machine vision lens. Confirm the required field of view and working distance before treating any camera and lens as a selected combination.

Machine vision lenses16 mm, 1.1", 20 MP, C-mount machine vision lens, F2.8-22, <0.3% distortion (LS-FFL-0567)LS-FFL-0567
Type
Machine vision fixed
Sensor format
1.1"
Mount
C-mount
Resolution
16-25 MP
$679.00View partBuild a system with it

Before ordering, record the required object sampling, overlap geometry, permissible registration error, acquisition timing, and whether the output is for display or measurement. Those requirements matter more than the feature detector's name.

Start a candidate setup in the camera configurator, or send representative original images and your inspection tolerance through application support to review the acquisition requirements.

Questions

Why can two successful pairwise stitches fail when combined?

Two composites may use different canvas origins, crops, scales, and blending decisions. Both also contain the middle image, potentially with different interpolation. Registering those composites adds avoidable ambiguity. Estimate geometry from the originals, retain the transforms, and render the original images directly into one shared output frame.

Do the first and third images need to overlap?

No. Adjacent overlap is sufficient when the first and third images each register reliably to the middle image. Overlap between the outer images can provide an additional consistency check, but it is not required for this arrangement. Each adjacent overlap still needs enough distinctive, well-distributed image information.

How many matches are enough for a homography?

A homography needs at least four correspondences in general position, but that minimum offers little protection against poor localization or incorrect matches. Accept the mapping using additional evidence: inlier distribution, reprojection residuals, plausible geometry, and alignment of independent landmarks across the inspected overlap.

Can blending remove doubled edges in the overlap?

Usually not. Blending changes how overlapping intensities are combined; it does not make displaced features occupy the same position. Check transform direction, registration quality, parallax, and scene motion first. A seam can avoid some visible disagreements, but it does not establish dimensional accuracy.

When is a single homography unsuitable for stitching?

Reject a single homography when translated viewpoints observe meaningful depth variation that must align throughout the scene. Also investigate severe lens distortion or scene motion before accepting the model. A planar inspection surface or rotation around a common projection center is a more suitable geometric starting point.