License YOLO
Back to Ultralytics Glossary

Image Stitching

Image stitching aligns and blends overlapping images into a continuous panorama or mosaic using feature matching, warping, and seam blending.

Image stitching, also called photo stitching, aligns and combines two or more overlapping images into one continuous view. The overlap tells the software where the images fit together: a landmark near the right edge of one photo might appear near the center of the next. Lining up those two appearances lets the composite cover more of the scene than either photo alone. Some photo editors also use "photo stitching" to mean arranging separate images side by side in a collage.

How Image Stitching Works#

Image registration estimates where each image belongs in a shared coordinate system. It often starts with image matching. A method such as Scale-Invariant Feature Transform (SIFT) finds distinctive points and describes the pixels around them so the same details can be recognized in another view. In Matthew Brown and David Lowe's 2007 automatic panorama method, random sample consensus (RANSAC) fits candidate transformations from small subsets of matches and looks for the fit with the most geometrically consistent matches. Classical stitching requires no model training. A learned matcher such as LoFTR can also find correspondences in areas where traditional keypoint detectors find too few.

A homography can align views of a flat surface or views taken by rotating a camera about its optical center. An affine transformation can handle simpler changes, such as shifts and rotations between flat scans. With many views, bundle adjustment refines their alignment jointly, reducing the drift that can build up when each image is aligned only to its neighbor. Warping applies the estimated alignment to place the images on a shared canvas.

Stitching continues after registration. Exposure compensation reduces brightness differences, seam selection determines where one view gives way to the next, and blending smooths the transition. Multiband blending uses wider transitions for gradual changes in tone and narrower ones for fine details.

How to Stitch Two Images Together#

Start with two images that share recognizable scene detail. In Photoshop, File > Automate > Photomerge aligns overlapping photos and uses layer masks to blend them. In Python, the OpenCV Stitcher estimates alignment and composites the result. With opencv-python installed, the example below stitches two overlapping crops of a bus photograph. The SCANS mode uses an affine model, which suits the sideways shift between the crops.

from urllib.request import urlretrieve

import cv2

path, _ = urlretrieve("https://ultralytics.com/images/bus.jpg", "bus.jpg")
image = cv2.imread(path)
width = image.shape[1]

# Create two views with a shared center region.
left = image[:, : 4 * width // 5].copy()
right = image[:, width // 5 :].copy()

stitcher = cv2.Stitcher_create(cv2.Stitcher_SCANS)
status, stitched = stitcher.stitch([left, right])
if status != cv2.Stitcher_OK:
    raise RuntimeError(f"Stitching failed with status {status}")
cv2.imwrite("stitched_bus.jpg", stitched)

The output, stitched_bus.jpg, combines the outer portions of both crops on one canvas. The shared center appears once rather than twice, as it would if the crops were placed side by side.

Why Image Stitches Fail#

There is no universal overlap percentage. Texture and the spread of matching points matter: a strip of blank sky offers few landmarks, while repeating windows can make a stitcher align the wrong parts of a facade. When the camera moves sideways, nearby objects shift relative to the background. This depth-dependent shift, called parallax, can leave a foreground edge doubled even when the background lines up. A moving subject can also appear twice if it crosses the overlap between exposures. A brightness step along an otherwise aligned join points to exposure compensation or blending. These artifacts can occur together.

Where Image Stitching Is Used#

  • Panoramic photography: Successive views capture a wider angle than one exposure. Cylindrical or spherical projections accommodate wide fields of view that would stretch at the edges on a flat projection.
  • Microscopy: Fiji's stitching plugin aligns overlapping microscope tiles into a larger view of a specimen without having to capture it at lower magnification.
  • Aerial mapping: OpenDroneMap combines overlapping aerial photos into an orthomosaic. On the finished mosaic, Ultralytics YOLO high-resolution tiling runs object detection on crops with known positions, preserving small-object detail that whole-image resizing can lose. An orthomosaic has a uniform map scale because its geometry is corrected for camera tilt and terrain relief, allowing ground distances to be measured.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning