pingwyn.affine_correct

Perform an affine transformation on an image. The affine transformation scales and skews the supplied image. The transformation parameters are determined by reshaping two vectors in vectors_from (e.g. unit cell lattice vectors measured in the image) to the norms and angle they are supposed to be in lattice_to (e.g. the actual/theoretical unit cell).

The main purpose of this function is to correct topography images for miscalibrated scanners or for drift.

param image:

The image to transform

type image:

pingwyn.Image

param vectors_from:

The vectors that need to be transformed. This must be a numpy array containing two 2D vectors, i.e. np.array([[x1, y1], [x2, y2]]). Note: the vectors here assume x,y-based indexing, not i,j-based indexing.

type vectors_from:

numpy.ndarray

param lattice_to:

The lattice that the vectors (and thus the image) should transform towards. This parameter holds two norms (or unit cell lengths) and the angle (in radians) between the two vectors, i.e. [a1, a2, angle].

type lattice_to:

tuple or list or np.ndarray

param fill_value:

The value to fill blank pixels with after the transformation. Default: 0.0

type fill_value:

float

returns:

The transformed/corrected image.

rtype:

pingwyn.Image