Skip to main content

Stitch arbitrary or consecutive sets of images

Project description

image-stitcher

Python library for general mass image stitching.

Setup

git clone --depth=1 -b master git@github.com:codegallivant/image-stitcher.git
cd image-stitcher
pip install .

Usage

An example can be found in tests/.

Arbitrary stitching

Relations in an arbitrarily arranged set of images are automatically determined. Each related collection found is stitched together.

import os
from image_stitcher.stitcher import ArbitraryStitcher

dir_path = "path/to/dir"
filepaths = [os.path.join(dir_path, f) for f in os.listdir(dir_path)]

arbs = ArbitraryStitcher(
    log_level = 2,
    output_dir = "stitches/",
    min_match_count = 5,
    lowes_ratio_threshold = 0.65,
    algorithm = 0,
    matcher = 0,
    type = 0,
    resize = None,
    consecutive_range = None,
    blend_processor = lambda x: x,
    blender = 1,
    ref_image_contrib = 0.2,
    images = None, 
    filepaths = dir_path, 
    with_tqdm = True
)

collections = arbs.get_collections()
stitched = arbs.stitch_collections(collections)

Consecutive stitching

  • Images are sequentially stitched without pre-determining relations in the large set.
  • Optimizations coded in allow this to stitch HD images at 5Hz and SD images at up to 10Hz. Suitable for applications such as live aerial drone mapping.
import os
from image_stitcher.stitcher import ConsecutiveStitcher


dir_path = "path/to/dir"
filepaths = [os.path.join(dir_path, f) for f in os.listdir(dir_path)]


def load_image(filepath, to_resize = None):
    image = cv2.imread(filepath)
    return resize_image(image, to_resize)

cons = ConsecutiveStitcher(
    log_level = 2,
    output_dir = "stitches/",
    min_match_count = 5,
    lowes_ratio_threshold = 0.65,
    algorithm = 0,
    matcher = 0,
    type = 0,
    resize = None,
    consecutive_range = None,
    blend_processor = lambda x: x,
    blender = 1,
    ref_image_contrib = 0.2,
    consecutive_range = 1,
    backup_interval = False,
    consecutive_volatility_threshold = 4,
)

for filepath in filepaths:
    cons.stitch_consecutive(load_image(filepath))

Synchronous stitching

Consecutively stitches a second set of images using the same transformations calculated when stitching the first set. Can be used to stitch depth images from corresponding RGB images.

from image_stitcher.stitcher import ConsecutiveStitcher


class SynchronizedStitcher:
    def __init__(self, rgb_args=None, depth_args=None, points=None):
        self.rgb_stitcher = ConsecutiveStitcher(**rgb_args)
        self.depth_stitcher = ConsecutiveStitcher(**depth_args)

    def stitch(self, rgb_image, depth_image = None):
        first_stitch = self.rgb_stitcher.stitch_count == 0
        tf = self.rgb_stitcher.stitch_consecutive(rgb_image)
        if not (depth_image is None):
            if not first_stitch:
                if self.rgb_stitcher.stitch_count > self.depth_stitcher.stitch_count:
                    self.depth_stitcher.save_and_reset()
            self.depth_stitcher.stitch_consecutive(depth_image, tf)
        return tf


sync_st = SynchronizedStitcher(
    rgb_args={
        "output_dir": "path/to/rgbdir",
        "matcher": 1,
        "algorithm": 1,
        "backup_interval": 50,
        "consecutive_range": 2,
        "blender": 1,
        "log_level": 2
    },
    depth_args={
        "output_dir": "path/to/depthdir",
        # "blend_processor": lambda x: utils.color_map(x),
        "backup_interval": 50,
        "blender": 0,
        "ref_image_contrib": 0.5,
        "log_level": 2
    }
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image_stitcher-0.9.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

image_stitcher-0.9.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file image_stitcher-0.9.0.tar.gz.

File metadata

  • Download URL: image_stitcher-0.9.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for image_stitcher-0.9.0.tar.gz
Algorithm Hash digest
SHA256 b8530d15246cbc286c1c9c406c5c84a07c85c94e30e030b38aaebbbacd96665d
MD5 d7cbe853ddabc1e5d78f1c69257de853
BLAKE2b-256 399a3fa7dd4c856feef189211a7827e4dec858c1d24b8bf439be16ecaafc2ad0

See more details on using hashes here.

File details

Details for the file image_stitcher-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: image_stitcher-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for image_stitcher-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ede36825972a5713144d36af4338cb75ba51433e058d4eb8ebc0ec5b6fde945
MD5 6f89c4f0ee0643332f839f8575430f71
BLAKE2b-256 5df8a38fbe16602ef4cc26129359a5eb8ed23f8e40542f42a45156f3ca6ca3f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page