rotate_image

sofia_redux.instruments.forcast.rotate.rotate_image(image, angle, center=None, order=1, shift=None, output_shape=None, cval=nan, mode='constant', clip=True, inverse=False, threshold=0.5)[source]

Rotate an image about a point by a given angle.

Rotation occurs using the same logic as rotate_coordinates_about() followed by an interpolation of the original image onto the rotated coordinates via splines of the supplied order.

Parameters:
imagenumpy.ndarray

The image to rotate with n_dimensions and of shape (shape,).

angleint or float

The angle to rotate the image about center in degrees.

centernumpy.ndarray, optional

The coordinate for the center of rotation of shape (n_dimensions,) using the Numpy (y, x) convention. The default is (image.shape-1)/2.

orderint, optional

The spline interpolation order. Must be in the range 0-5.

shiftnumpy.ndarray, optional

An optional shift to apply prior to the forward transform rotation of shape (n_dimensions,) using the Numpy (y, x) convention. Please see rotate_coordinates_about() for further details.

output_shapetuple (int)

The output shape for the rotated image of length n_dimensions using the Numpy (y, x) ordering convention.

cvalint or float, optional

Used in conjunction with mode`='constant' to fill in values outside the boundaries of `image.

modestr, optional

Can take values of {‘constant’, ‘edge’, ‘symmetric’, ‘reflect’, ‘wrap’} for which points outside the boundaries of the input are filled according to the given mode. Modes match the behaviour of np.pad().

clipbool, optional

Whether to clip the output to the range of values of the input image. This is enabled by default, since higher order interpolation may produce values outside the given input range.

inversebool, optional

If True, perform the inverse rotation (rotate by -angle). Please see rotate_coordinates_about() for further details.

thresholdfloat, optional

Used in conjunction with cval`=NaN and `mode`='constant'.  Should generally take values in the range -1 to 1 with a default of 0.5. This is used to better apply NaN `cval boundaries as expected. Points inside the boundaries are mapped to 1, and values outside are mapped to -1. Points which map to values >= threshold are considered valid, while others will be set to NaN in the output. Please see map_coordinates() for further details.

Returns:
rotatednumpy.ndarray

The rotated image with the same shape as image or output_shape.