shift_distortion_correction

shift_distortion_correction(images, reg_regions=((0, 0, 0.1, 0.1), (0.9, 0, 1, 0.1), (0, 0.9, 0.1, 1), (0.9, 0.9, 1, 1)), absolute=False)[source]

Shift and distortion (=strain) correction for all images in a stack.

This function computes the relative translation and the warp between the images with the first image in the stack as the reference image. The images are translated into the coordinate system of the first image. Black areas in the resulting images are the result of the transformation into the reference coordinate system.

Four rectangular areas must be chosen from which the global shift and distortion relative to each other is computed.

Parameters
images: list, ImageStack

Images represented as np.ndarray. All images must have the same dimensionality! If the width and height of the images is not the same, they are cut to the shape of the smallest image.

reg_regions: tuple

A tuple of four tuples containing the upper left and lower right corners of the rectangles for the areas where the phase-cross-correlation is computed. E.g. ((x1, y1, x2, y2), (…), (…), (…)) where x1, y1 etc. can be relative dimensions of the image or the absolute coordinates in pixel. Default is relative. For relative coordinates enter values from 0-1. If values above 1 are given, absolute coordinate values are assumed.

absolute: bool

True if absolute and False if relative values are given in reg_regions

Returns
out: list, ImageStack

list or ImageStack with the corrected images.

Notes

For this algorithm to work properly it is advantageous to have markers on reach corner of the images (like crosses). Make sure that the rectangular areas cover the markers in each image. If no distinct features that can be tracked are given, this function can result in wrong shift and distortion corrections. In this case, make sure to check the results before further image processing steps.