Skip to content

nextcv.image.stitching ⚓︎

Generalized image stitching framework.

Simple, extensible architecture for stitching images from multiple cameras.

CLASS DESCRIPTION
AdditiveCompensator

Sequential additive bias correction.

ExposureCompensator

Abstract base class for exposure compensation strategies.

HorizontalStitcher

Stitch cameras arranged horizontally (left-to-right).

ImageStitcher

Abstract base class for image stitching.

LeftRightStitcher

Stitch cameras arranged horizontally (left-to-right).

NoOpCompensator

No compensation - returns images unchanged.

Rect

Image region defined by top-left corner and dimensions.

Tile

A tile within a canvas for image stitching.

nextcv.image.stitching.AdditiveCompensator ⚓︎

Bases: ExposureCompensator

Sequential additive bias correction.

Computes median intensity difference in overlap regions and applies additive corrections. First image is used as reference. Each subsequent image is corrected to match the already-corrected previous image.

Good for small-to-medium brightness differences in thermal cameras.

METHOD DESCRIPTION
__call__

Compute and apply additive bias corrections.

__call__ ⚓︎

__call__(tiles: List[Tile], images: List[ndarray]) -> List[ndarray]

Compute and apply additive bias corrections.

_compute_bias_between_tiles staticmethod ⚓︎

_compute_bias_between_tiles(tile_i: Tile, tile_j: Tile, img_i: ndarray, img_j: ndarray) -> float

Compute intensity bias between two overlapping tiles.

PARAMETER DESCRIPTION
tile_i

First tile (reference)

TYPE: Tile

tile_j

Second tile (to be corrected)

TYPE: Tile

img_i

Warped image from tile_i

TYPE: ndarray

img_j

Warped image from tile_j

TYPE: ndarray

RETURNS DESCRIPTION
float

Bias to add to img_j to match img_i (float scalar)

nextcv.image.stitching.ExposureCompensator ⚓︎

Bases: ABC

Abstract base class for exposure compensation strategies.

Compensators compute and apply corrections to warped images to minimize intensity differences in overlap regions.

METHOD DESCRIPTION
__call__

Compute and apply corrections to warped images.

__call__ abstractmethod ⚓︎

__call__(tiles: List[Tile], warped_images: List[ndarray]) -> List[ndarray]

Compute and apply corrections to warped images.

PARAMETER DESCRIPTION
tiles

List of tiles with rect, mask, and weights

TYPE: List[Tile]

warped_images

List of warped images (one per tile)

TYPE: List[ndarray]

RETURNS DESCRIPTION
List[ndarray]

List of corrected images

nextcv.image.stitching.HorizontalStitcher ⚓︎

HorizontalStitcher(cameras: List[CameraType], compensator: Optional[ExposureCompensator] = None)

Bases: ImageStitcher[PinholeCamera]

Stitch cameras arranged horizontally (left-to-right).

nextcv.image.stitching.ImageStitcher ⚓︎

ImageStitcher(cameras: List[CameraType], compensator: Optional[ExposureCompensator] = None)

Bases: ABC, Generic[CameraType]

Abstract base class for image stitching.

PARAMETER DESCRIPTION
cameras

List of cameras to stitch

TYPE: List[CameraType]

compensator

Exposure compensator to use. Defaults to NoOpCompensator()

TYPE: Optional[ExposureCompensator] DEFAULT: None

METHOD DESCRIPTION
__call__

Stitch images into panorama.

create_warp_tiles

Create normalized warp tiles for all cameras.

stitch

Stitch images into the virtual camera.

__call__ ⚓︎

__call__(images: List[ndarray]) -> ndarray

Stitch images into panorama.

_create_virtual_cam abstractmethod ⚓︎

_create_virtual_cam() -> CameraType

Create virtual camera defining output coordinate system.

_sanity_checks ⚓︎

_sanity_checks(images: List[ndarray]) -> None

Sanity checks for the images.

create_warp_tiles staticmethod ⚓︎

create_warp_tiles(cameras: List[CameraType], canvas: CameraType) -> List[Tile]

Create normalized warp tiles for all cameras.

stitch ⚓︎

stitch(images: List[ndarray]) -> ndarray

Stitch images into the virtual camera.

nextcv.image.stitching.LeftRightStitcher ⚓︎

LeftRightStitcher(left_camera: PinholeCamera, right_camera: PinholeCamera)

Bases: HorizontalStitcher

Stitch cameras arranged horizontally (left-to-right).

nextcv.image.stitching.NoOpCompensator ⚓︎

Bases: ExposureCompensator

No compensation - returns images unchanged.

Fastest option. Use when images are already well-balanced or when exposure differences are negligible.

METHOD DESCRIPTION
__call__

Return images unchanged.

__call__ ⚓︎

__call__(tiles: List[Tile], warped_images: List[ndarray]) -> List[ndarray]

Return images unchanged.

nextcv.image.stitching.Rect dataclass ⚓︎

Rect(x: int, y: int, w: int, h: int)

Image region defined by top-left corner and dimensions.

PARAMETER DESCRIPTION
x

TYPE: int

y

TYPE: int

w

TYPE: int

h

TYPE: int

METHOD DESCRIPTION
clamp_to

Clamp region to bounds, return None if no overlap.

intersect

Compute intersection with another rectangle.

numpy_slices

Return (y_slice, x_slice) for numpy indexing with optional offset.

ATTRIBUTE DESCRIPTION
s

Shorthand for numpy_slices() - returns (y_slice, x_slice).

TYPE: Tuple[slice, slice]

s property ⚓︎

Shorthand for numpy_slices() - returns (y_slice, x_slice).

Usage

arr[rect.s] = value

clamp_to ⚓︎

clamp_to(max_w: int, max_h: int) -> Optional[Rect]

Clamp region to bounds, return None if no overlap.

intersect ⚓︎

intersect(other: Rect) -> Optional[Rect]

Compute intersection with another rectangle.

numpy_slices ⚓︎

numpy_slices(offset_x: int = 0, offset_y: int = 0) -> Tuple[slice, slice]

Return (y_slice, x_slice) for numpy indexing with optional offset.

nextcv.image.stitching.Tile dataclass ⚓︎

Tile(rect: Rect, maps: Tuple[ndarray, ndarray], mask: ndarray, weights: ndarray)

A tile within a canvas for image stitching.

PARAMETER DESCRIPTION
rect

TYPE: Rect

maps

TYPE: Tuple[ndarray, ndarray]

mask

TYPE: ndarray

weights

TYPE: ndarray

METHOD DESCRIPTION
from_camera_pair

Create a warp tile from a camera.

update_weights

Update the weights.

warp_image

Warp source image to this tile.

from_camera_pair classmethod ⚓︎

from_camera_pair(camera: CameraType, canvas: CameraType) -> Optional[Tile]

Create a warp tile from a camera.

update_weights ⚓︎

update_weights(weights: ndarray) -> Tile

Update the weights.

warp_image ⚓︎

warp_image(src_img: ndarray) -> ndarray

Warp source image to this tile.