Skip to contents

image_stitch() merges multiple overlapping planar images (e.g. root scanner tiles, oversized plant leaves, bench scans, or drone orthomosaic patches) into a single seamless composite without requiring OpenCV, Python, or external software.

The native pipeline performs:

  1. Multi-Scale Normalized Cross-Correlation (NCC): Coarse-to-fine registration finding the exact sub-pixel horizontal and vertical shifts between adjacent tiles.

  2. Cosine-Smooth Seam Feathering: Eliminates visible seam lines and exposure steps by applying non-linear cosine weighted transitions across the overlap zone.

  3. Dynamic Canvas Expansion: Recursively chains two or more images into a single composite image array.

Usage

image_stitch(
  images,
  direction = c("horizontal", "vertical", "auto"),
  blend = TRUE,
  overlap_hint = 0.2,
  plot = FALSE,
  return_details = FALSE,
  verbose = TRUE
)

Arguments

images

A list of Image objects or a character vector of file paths.

direction

Stitching direction: "horizontal" (left-to-right), "vertical" (top-to-bottom), or "auto" (automatically chosen based on best correlation peak).

blend

Logical. If TRUE (default), applies smooth seam feathering across overlapping image bands. If FALSE, places images directly with a sharp cut.

overlap_hint

Expected fractional overlap between adjacent images (default: 0.2 = 20%).

plot

Logical. If TRUE, plots the stitched result.

return_details

Logical. If TRUE, returns a named list with the stitched image and registration diagnostics (shifts, NCC scores, overlap dimensions). If FALSE (default), returns the stitched Image directly.

verbose

Logical. If TRUE (default), displays progress messages.

Value

An Image object (or a named list if return_details = TRUE).

Author

Tiago Olivoto tiagoolivoto@gmail.com

Examples

if (FALSE) { # interactive()
library(pliman)

# Stitch two overlapping leaf scans
imgs <- list(
  image_read("leaf_left.jpg"),
  image_read("leaf_right.jpg")
)
stitched <- image_stitch(imgs, direction = "horizontal")
plot(stitched)
}