ai_ct_scans.phase_correlation module

ai_ct_scans.phase_correlation.align_via_phase_correlation_2d(image_1, image_2)

Aligns 2D image_2 to 2D image_1 via phase correlation

Parameters
  • image_1 (np.ndarray) – An image

  • image_2 (np.ndarray) – An image, expected to be similar to image_1 with a translation being the major transform

  • them (between) –

Returns

image_2 after shifting to align with image_1

Return type

(np.ndarray)

ai_ct_scans.phase_correlation.find_shift_via_phase_correlation_2d(image_1, image_2)

Get the shift from 2D image_1 to 2D image_2 via phase correlation

Parameters
  • image_1 (np.ndarray) – An image

  • image_2 (np.ndarray) – An image, expected to be similar to image_1 with a translation being the major

  • transform

  • them (between) –

Returns

The [col, row] translation between image_1 and image_2

Return type

(np.ndarray)

ai_ct_scans.phase_correlation.shift_image_2d(image, shift)

Shifts image by shift via skimage SimilarityTransform

Parameters
  • image (np.ndarray) – An image

  • shift (np.ndarray) – Two ints

Returns

An image

Return type

(np.ndarray)

ai_ct_scans.phase_correlation.shift_nd(image, shift)

Shifts an image across an arbitrary number of dimensions by a vector shift defining the shift in each dimension

Parameters
  • image (ndarray) – an image

  • shift (ndarray) – 1D vector of ints by which to shift the image

Returns

The original image, shifted by the specified amount, with border regions filled in with zeros

Return type

(ndarray)

ai_ct_scans.phase_correlation.shift_via_phase_correlation_nd(images, apply_lmr=True, apply_zero_crossings=True, lmr_filter_type=None, lmr_radius=3, zero_crossings_thresh='auto')

Gets the shift between the zeroth image and all images (including zeroth) in a list of n-dimensional images via phase correlation

Parameters
  • lmr_filter_type (filter) – (None or ndarray): The filter to apply to find the local mean, typically a shape centred at

  • [0 (at) –

  • 0]

  • apply_zero_crossings (0]) – whether to mask images to points where the images cross zero before finding shift,

  • zero_crossings_thresh (float or 'auto') – The amount by which adjacent pixel values must differ while crossing 0

  • 'auto' (to be counted as a crossing point. If) –

  • the (chooses the bin edge value prior to the maximum counts in) –

  • values (smoothed histogram of pixel) –

  • lmr_radius (float) – if lmr_filter_type is none, an n dimensional circle of radius lmr_radius is used as the

  • lmr_filter_type – The filter to apply to find the local mean, typically a shape centred

  • [0 – whether to mask images to points where the images cross zero before

  • apply_zero_crossings – whether to mask images to points where the images cross zero before

  • shift (finding) –

  • step (effectively a weighted edge detection) –

  • apply_lmr (bool) – whether to apply local mean removal before optionally appling zero crossings and then shift

  • points (detection - recommended to use this if using apply_zero_crossings as it should create more zero crossing) –

  • images (list of ndarrays) – The set of images to discover shifts relative to the zeroth image for

Returns

The [(row, col, depth, dimension_4, …)_0, …] shift from images[0] to overlay on images[n]

Return type

(list of tuples)

ai_ct_scans.phase_correlation.shifts_via_local_region(images, local_coords, region_widths, apply_lmr=True, apply_zero_crossings=True, lmr_filter_type=None, lmr_radius=None, zero_crossings_thresh='auto')

Find the shifts between images using a reduced view extracted around the same coordinates in each image, optionally pre-processing via local mean removal and zero crossings before applying phase correlation

Parameters
  • images (list of ndarrays) – The set of images to discover shifts relative to the zeroth image for

  • local_coords (list of ints) – The coordinates of the central point of interest in both images

  • region_widths (tuple of tuples of ints or tuple of ints) – The spacing either side of the local coordinate to

  • dimension (extract a slice of the images with. Can either be a single int for each) –

  • symmetric (i.e. take a) –

  • spacing

  • 2 (or a tuple of tuples of ints where each sub-tuple is length) –

  • of (i.e. a different spacing either side) –

  • coordinate (local) –

  • apply_lmr (bool) – whether to apply local mean removal before optionally appling zero crossings and then shift

  • apply_zero_crossings (bool) – whether to mask images to points where the images cross zero before finding shift,

  • step (effectively a weighted edge detection) –

  • lmr_filter_type (None or ndarray) – The filter to apply to find the local mean, typically a shape centred at

  • [0

  • 0]

  • lmr_radius (float) – if lmr_filter_type is none, an n dimensional circle of radius lmr_radius is used as the

  • filter

  • zero_crossings_thresh (float or 'auto') – The amount by which adjacent pixel values must differ while crossing 0

  • crossing (to be counted as a) –

Returns

A vector shift for each each image in images relative to the zeroth image (including self-shift at the zeroth output position)

Return type

(list of ndarrays)