nabu.stitching.overlap module

class nabu.stitching.overlap.OverlapStitchingStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

MEAN = 'mean'
COSINUS_WEIGHTS = 'cosinus weights'
LINEAR_WEIGHTS = 'linear weights'
CLOSEST = 'closest'
IMAGE_MINIMUM_DIVERGENCE = 'image minimum divergence'
HIGHER_SIGNAL = 'higher signal'
class nabu.stitching.overlap.OverlapKernelBase[source]

Bases: object

class nabu.stitching.overlap.ImageStichOverlapKernel(stitching_axis: int, frame_unstitched_axis_size: tuple, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, overlap_size: int = None, extra_params: dict | None = None)[source]

Bases: OverlapKernelBase

Stitch two images along Y (axis 0 in image space)

Parameters:
  • stitching_axis – axis along which stitching is operate. Must be in ‘0’, ‘1’

  • frame_unstitched_axis_size – according to the stitching axis the stitched framed will always have a constant size: * If stitching_axis == 0 then it will be the frame width * If stitching_axis == 1 then it will be the frame height

  • stitching_strategy – stategy / algorithm to use in order to generate the stitching

  • overlap_size – size (int) of the overlap (stitching) between the two images

  • extra_params – possibly extra parameters to operate the stitching

DEFAULT_HIGH_FREQUENCY_THRESHOLD = 2
property stitched_axis: int
property unstitched_axis: int

util function. The kernel is operating stitching on images along a single axis (stitching_axis). This property is returning the other axis.

property overlap_size: int
property img_2: ndarray
property weights_img_1: ndarray | None
property weights_img_2: ndarray | None
property stitching_strategy: OverlapStitchingStrategy
compute_weights()[source]
stitch(img_1, img_2, check_input=True) tuple[source]

Compute overlap region from the defined strategy

nabu.stitching.overlap.compute_image_minimum_divergence(img_1: ndarray, img_2: ndarray, high_frequency_threshold, stitching_axis: int)[source]

Algorithm to improve treatment of high frequency.

It split the two images into two parts: high frequency and low frequency.

The two low frequency part will be stitched using a ‘sinusoidal’ / cosinus weights approach. When the two high frequency parts will be stitched by taking the lower divergent pixels

nabu.stitching.overlap.compute_image_higher_signal(img_1: ndarray, img_2: ndarray)[source]

the higher signal will pick pixel on the image having the higher signal. A use case is that if there is some artefacts on images which creates stripes (from scintillator artefacts for example) it could be removed from this method

nabu.stitching.overlap.check_overlaps(frames: tuple | ndarray, positions: tuple, axis: int, raise_error: bool)[source]

check over frames if there is a single overlap other juxtaposed frames (at most and at least)

Parameters:
  • frames – liste of ordered / sorted frames along axis to test (from higher to lower)

  • positions – positions of frames in 3D space as (position axis 0, position axis 1, position axis 2)

  • axis – axis to check

  • raise_error – if True then raise an error if two frames don’t have at least and at most one overlap. Else log an error