← All articles 8 min read

Photo Stitching: How to Create Panoramas and Mosaics

Photo stitching joins multiple overlapping photos into a single wide or tall image — typically a panorama. The software detects matching features across photos, aligns them geometrically, warps them to correct for lens distortion, and blends the seams so the result looks like one continuous shot.

This is different from combining images side-by-side in a grid, which arranges separate photos without blending. Photo stitching creates a seamless composite from overlapping source material.

After stitching, the resulting panorama often needs compression or resizing for web or email sharing — panoramic images can easily exceed 10,000 pixels wide.


How Photo Stitching Works

Every stitching tool follows the same fundamental pipeline:

1. Feature Detection

The software identifies distinctive points in each photo — corners, edges, high-contrast areas. Algorithms like SIFT (Scale-Invariant Feature Transform) or ORB (Oriented FAST and Rotated BRIEF) find hundreds to thousands of feature points per image.

2. Feature Matching

For each pair of overlapping photos, the software matches features from one image to the same real-world point in the other. Good matches align; bad matches (from repetitive patterns, moving objects) get filtered out by RANSAC or similar outlier rejection.

3. Homography Estimation

From the matched features, the software computes a geometric transformation (homography matrix) that maps one image's coordinate system onto the other's. This accounts for camera rotation, focal length, and lens distortion.

4. Warping

Each image is warped (reprojected) onto a common coordinate plane — cylindrical for standard panoramas, spherical for 360° shots, or rectilinear for small fields of view. The projection type affects how straight lines and horizons appear in the final image.

5. Blending

The warped images overlap in transition zones. Blending algorithms (feathering, multiband blending, gradient-domain blending) smooth the transitions so that exposure differences, vignetting, and slight color shifts between frames become invisible.


Shooting Photos for Stitching

The quality of the stitch depends more on how you shoot than which software you use.

Guideline Why
30-50% overlap between frames Feature matching needs sufficient shared content. Less than 20% overlap causes alignment failures.
Lock exposure and white balance Auto exposure changes between frames create visible banding in the final panorama. Use manual mode or AE-lock.
Rotate the camera, do not translate it Translation causes parallax — nearby objects shift position between frames. Rotate around the lens's nodal point (or as close as possible).
Keep the camera level A tilted horizon across frames makes warping harder and wastes output resolution on black triangles. Use a tripod with a leveled head if possible.
Shoot left to right (or top to bottom) systematically Consistent direction helps you track coverage and ensures you do not miss a section.
Avoid moving subjects in overlap zones A person walking across the overlap area appears twice (ghosting) or partially. Time your shots or use ghost removal in post.

Tripod vs Handheld

A tripod with a panoramic head produces the best results — consistent rotation, no vertical drift, minimal parallax. But modern stitching software handles handheld shots surprisingly well for standard horizontal panoramas. Handheld breaks down for multi-row stitches and 360° spherical panoramas.


Method 1: Photoshop Photomerge (v26.3)

Photoshop's Photomerge is the simplest desktop option for standard panoramas.

Steps

  1. Open Photoshop v26.3.
  2. Go to File → Automate → Photomerge.
  3. Click Browse and select your overlapping photos (3-12 images for a typical panorama).
  4. Choose a layout:
    • Auto — Photoshop picks the best projection. Good default.
    • Cylindrical — Standard for wide panoramas (90°-180° field of view). Keeps horizons straight.
    • Spherical — For very wide or multi-row panoramas (180°+).
    • Perspective — Anchors one image and warps others to match its perspective. Good for small fields of view.
  5. Enable Blend Images Together (seam blending). Optionally enable Vignette Removal and Geometric Distortion Correction if your lens has noticeable falloff or barrel distortion.
  6. Click OK. Photoshop aligns, warps, and blends the images onto separate layers with layer masks.
  7. Crop the result: Image → Crop to remove the irregular edges (black triangles from warping).
  8. Flatten: Layer → Flatten Image. Export as JPG or TIFF.

Photomerge handles 3-15 images reliably. For more than 15 or for multi-row stitches, use Hugin or dedicated panorama software.


Method 2: Hugin (v2023.0.0) — Free and Open Source

Hugin is the most powerful free stitching tool, with full control over projection, control points, lens calibration, and optimization.

Steps

  1. Download Hugin v2023.0.0 (hugin.sourceforge.io). Available for Windows, macOS, and Linux. License: GPL-2.0.
  2. Load images: Drag your photos into Hugin's Photos tab.
  3. Align: Click Align in the toolbar. Hugin's CPFind detects and matches control points automatically. The Fast Preview window shows the initial stitch.
  4. Optimize: If the alignment is off, go to the Optimizer tab. Run Geometric + Photometric optimization. This adjusts each image's yaw, pitch, roll, lens distortion, and exposure compensation.
  5. Projection: In the Fast Preview window, choose your projection:
    • Equirectangular — for 360° panoramas
    • Cylindrical — for wide horizontal panoramas
    • Rectilinear — for narrow fields of view (keeps straight lines straight)
    • Mercator, Panini, Stereographic — specialty projections for architectural or artistic effects
  6. Crop: Drag the crop rectangle to exclude black edges.
  7. Stitch: Go to the Stitcher tab. Set output format (TIFF for maximum quality, JPEG for convenience). Click Stitch!.

Hugin's learning curve is steeper than Photoshop, but it handles multi-row panoramas, 360° spherical stitches, exposure bracketing (HDR panoramas), and gigapixel composites.


Method 3: Microsoft Image Composite Editor (ICE) v2.0 — Free (Windows)

ICE is a lightweight, streamlined stitcher from Microsoft Research. It does one thing well.

Steps

  1. Download ICE v2.0 (discontinued but still available from Microsoft Research archives). Windows only.
  2. Drag your photos into the ICE window.
  3. ICE automatically detects overlap, aligns, and stitches. No configuration needed.
  4. Choose a projection (Auto, Cylindrical, Spherical, or Mercator).
  5. Crop and export as JPEG, TIFF, or Photoshop PSD.

ICE is the fastest desktop option — typically stitches 10 images in under 30 seconds. The tradeoff: no manual control point editing, no multi-row support, and no advanced optimization. If ICE's automatic alignment fails, you cannot fix it manually.

Note: ICE was discontinued by Microsoft but the v2.0 installer remains widely available. It runs on Windows 10 and 11 without issues.


Method 4: Phone Built-In Panorama Mode

Every modern phone has a built-in panorama mode that stitches in real-time as you sweep the camera.

iPhone (iOS 18)

  1. Open the Camera app. Swipe to Pano mode.
  2. Tap the shutter button and slowly pan in the arrow direction.
  3. Keep the arrow centered on the guide line. Move too fast and iOS warns you.
  4. Tap the shutter again (or reach the end) to finish.
  5. The stitched panorama appears in your Photos library.

Android (Google Camera v9.3)

  1. Open the Camera app. Select Panorama (or Photo Sphere for 360°).
  2. Tap the shutter and pan slowly following the guide dots.
  3. The panorama is stitched automatically after capture.

Phone panoramas are convenient but limited: single-row only, no exposure control, and stitching quality degrades in low light or with fast-moving subjects. For the best quality, shoot individual frames and stitch on desktop.


Method 5: Python + OpenCV (v4.9.0)

For batch stitching or integration into automated pipelines:

import cv2  # OpenCV 4.9.0
from pathlib import Path

def stitch_images(image_paths: list[str], output_path: str) -> bool:
    images = [cv2.imread(p) for p in image_paths]
    stitcher = cv2.Stitcher.create(mode=cv2.Stitcher_PANORAMA)
    status, panorama = stitcher.stitch(images)

    if status == cv2.Stitcher_OK:
        cv2.imwrite(output_path, panorama)
        return True
    else:
        error_map = {
            cv2.Stitcher_ERR_NEED_MORE_IMGS: "Need more images",
            cv2.Stitcher_ERR_HOMOGRAPHY_EST_FAIL: "Homography estimation failed",
            cv2.Stitcher_ERR_CAMERA_PARAMS_ADJUST_FAIL: "Camera params adjustment failed",
        }
        print(f"Stitching failed: {error_map.get(status, 'Unknown error')}")
        return False

# Usage
paths = sorted(Path("panorama-frames").glob("*.jpg"))
stitch_images([str(p) for p in paths], "panorama.jpg")

OpenCV's Stitcher class handles feature detection, matching, homography, warping, and blending in a single call. For more control, use the individual modules: cv2.SIFT_create(), cv2.BFMatcher(), cv2.findHomography(), and cv2.warpPerspective().


Technique Input Output Use Case
Photo stitching Overlapping photos from same scene Seamless panorama Landscapes, real estate, architecture
Image combining Any photos Side-by-side grid or layout Collages, comparisons, social media
Photo montage Multiple photos Artistic composite blend Creative art, double exposures
HDR merging Same scene, different exposures Single high-dynamic-range image High-contrast scenes
Focus stacking Same scene, different focus points Single fully-sharp image Macro photography, product shots

Troubleshooting

Visible seams between images. Usually caused by exposure differences between frames. Fix: shoot in manual exposure mode, or use Hugin's photometric optimization to equalize brightness. Some stitchers (Photoshop, Hugin) offer vignette removal that helps.

Ghosting (duplicate objects). A moving object appears in the overlap zone of two frames. Fix: Photoshop's "Remove Ghosts" option during Photomerge, or Hugin's mask tool to exclude the ghost from one frame.

Warped straight lines (barrel/pincushion distortion). The lens distortion was not corrected during warping. Fix: in Hugin, load the correct lens profile in the Lens tab, or enable "Geometric Distortion Correction" in Photoshop.

Black triangles at edges. Normal — the warped images do not fill a perfect rectangle. Crop them out. For web use, some stitchers offer content-aware fill (Photoshop) to fill the gaps.

Alignment failure (software cannot stitch). Usually means insufficient overlap (< 20%), too much scene motion, or a featureless area (blank wall, clear sky) dominating the overlap zone. Reshoot with more overlap, or add manual control points in Hugin.


FAQ

How many photos do I need for a panorama? A minimum of 2, but 3-7 is typical for a standard horizontal panorama covering 90°-180°. For 360° panoramas, you need 12-20+ images depending on lens focal length. Wider lenses need fewer frames.

What is the best overlap percentage for stitching? 30-50%. Higher overlap gives the software more features to match and more blending room. Below 20%, most stitchers fail to find enough matching points.

Can I stitch vertical panoramas (vertorama)? Yes — same technique, but sweep the camera vertically instead of horizontally. Useful for tall buildings, waterfalls, and interior architecture. All methods above support vertical stitches.

What file format should I save my panorama in? TIFF for maximum quality and further editing. JPEG for sharing and web use. Panoramas can be very large (50-200 MB as TIFF), so compress the final image before sharing online.

Can I stitch photos taken at different times? Only if the lighting, camera position, and scene are identical. Stitching works by matching features between frames — if the scene changed between shots (different shadows, moved objects, changed lighting), the stitch will show visible artifacts.

What is the difference between panorama and photosphere? A panorama is a single-row horizontal (or vertical) sweep, typically 90°-360° horizontally. A photosphere is a full 360° × 180° spherical capture that covers every direction including straight up and down. Photospheres require multi-row stitching and equirectangular projection.