Skip to content

nabu.stitching.utils.utils

source module nabu.stitching.utils.utils

Classes

Functions

source enum ShiftAlgorithm(*args, **kwds)

Bases : Enum

All generic shift search algorithm

Attributes

  • NABU_FFT

  • SKIMAGE

  • ITK_IMG_REG_V4

  • NONE

  • CENTERED

  • GLOBAL

  • SLIDING_WINDOW

  • GROWING_WINDOW

  • SINO_COARSE_TO_FINE

  • COMPOSITE_COARSE_TO_FINE

Methods

source classmethod ShiftAlgorithm.from_value(value)

source find_frame_relative_shifts(overlap_upper_frame: numpy.ndarray, overlap_lower_frame: numpy.ndarray, estimated_shifts: tuple, overlap_axis: int, x_cross_correlation_function=None, y_cross_correlation_function=None, x_shifts_params: Optional[dict] = None, y_shifts_params: Optional[dict] = None)

:param overlap_axis: axis in [0, 1] on which the overlap exists. In image space. So 0 is aka y and 1 as x.

Raises

  • ValueError

source find_volumes_relative_shifts(upper_volume: VolumeBase, lower_volume: VolumeBase, overlap_axis: int, estimated_shifts, dim_axis_1: int, dtype, flip_ud_upper_frame: bool = False, flip_ud_lower_frame: bool = False, slice_for_shift: Union[int, str] = 'middle', x_cross_correlation_function=None, y_cross_correlation_function=None, x_shifts_params: Optional[dict] = None, y_shifts_params: Optional[dict] = None, alignment_axis_2='center', alignment_axis_1='center')

:param int dim_axis_1: axis 1 dimension (to handle axis 1 alignment)

Raises

  • NotImplementedError

  • ValueError

  • TypeError

source find_projections_relative_shifts(upper_scan: TomoScanBase, lower_scan: TomoScanBase, estimated_shifts: tuple, axis: int, flip_ud_upper_frame: bool = False, flip_ud_lower_frame: bool = False, projection_for_shift: Union[int, str] = 'middle', invert_order: bool = False, x_cross_correlation_function=None, y_cross_correlation_function=None, x_shifts_params: Optional[dict] = None, y_shifts_params: Optional[dict] = None)tuple

deduce the relative shift between the two scans. Expected behavior: * compute expected overlap area from z_translations and (sample) pixel size * call an (optional) cross correlation function from the overlap area to compute the x shift and polish the y shift from projection_for_shift

:param TomoScanBase scan_0: :param TomoScanBase scan_1: :param tuple estimated_shifts: 'a priori' shift estimation :param int axis: axis on which the overlap / stitching is happening. In the 3D space (sample, detector referential) :param bool flip_ud_upper_frame: is the upper frame flipped :param bool flip_ud_lower_frame: is the lower frame flipped :param Union[int,str] projection_for_shift: index fo the projection to use (in projection space or in scan space ?. For now in projection) or str. If str must be in (middle, first, last) :param bool invert_order: are projections inverted between the two scans (case if rotation angle are inverted) :param str x_cross_correlation_function: optional method to refine x shift from computing cross correlation. For now valid values are: ("skimage", "nabu-fft") :param str y_cross_correlation_function: optional method to refine y shift from computing cross correlation. For now valid values are: ("skimage", "nabu-fft") :param x_shifts_params: parameters to find the shift over x :param y_shifts_params: parameters to find the shift over y :return: relative shift of scan_1 with scan_0 as reference: (y_shift, x_shift) :rtype: tuple

:warning: this function will flip left-right and up-down frames by default. So it will return shift according to this information

Raises

  • ValueError

  • TypeError

  • NotImplementedError

source find_shift_correlate(img1, img2, padding_mode='reflect')

source find_shift_with_itk(img1: numpy.ndarray, img2: numpy.ndarray)tuple

Raises

  • ValueError

source from_slice_to_n_elements(slice_: Union[slice, tuple])

Return the number of element in a slice or in a tuple