def affine_transform(input, matrix, offset=0.0, output_shape=None, output_type=None, output=None, order=3, mode='constant', cval=0.0, prefilter=True):
    'Apply an affine transformation.\n\n    The given matrix and offset are used to find for each point in the\n    output the corresponding coordinates in the input by an affine\n    transformation. The value of the input at those coordinates is\n    determined by spline interpolation of the requested order. Points\n    outside the boundaries of the input are filled according to the given\n    mode. The output shape can optionally be given. If not given it is\n    equal to the input shape. The parameter prefilter determines if the\n    input is pre-filtered before interpolation, if False it is assumed\n    that the input is already filtered.\n\n    The matrix must be two-dimensional or can also be given as a\n    one-dimensional sequence or array. In the latter case, it is\n    assumed that the matrix is diagonal. A more efficient algorithms\n    is then applied that exploits the separability of the problem.\n    '
    if ((order < 0) or (order > 5)):
        raise RuntimeError('spline order not supported')
    input = numpy.asarray(input)
    if numpy.iscomplexobj(input):
        raise TypeError('Complex type not supported')
    if (output_shape is None):
        output_shape = input.shape
    if ((input.ndim < 1) or (len(output_shape) < 1)):
        raise RuntimeError('input and output rank must be > 0')
    mode = _extend_mode_to_code(mode)
    if (prefilter and (order > 1)):
        filtered = spline_filter(input, order, output=numpy.float64)
    else:
        filtered = input
    (output, return_value) = _ni_support._get_output(output, input, output_type, shape=output_shape)
    matrix = numpy.asarray(matrix, dtype=numpy.float64)
    if ((matrix.ndim not in [1, 2]) or (matrix.shape[0] < 1)):
        raise RuntimeError('no proper affine matrix provided')
    if (matrix.shape[0] != input.ndim):
        raise RuntimeError('affine matrix has wrong number of rows')
    if ((matrix.ndim == 2) and (matrix.shape[1] != output.ndim)):
        raise RuntimeError('affine matrix has wrong number of columns')
    if (not matrix.flags.contiguous):
        matrix = matrix.copy()
    offset = _ni_support._normalize_sequence(offset, input.ndim)
    offset = numpy.asarray(offset, dtype=numpy.float64)
    if ((offset.ndim != 1) or (offset.shape[0] < 1)):
        raise RuntimeError('no proper offset provided')
    if (not offset.flags.contiguous):
        offset = offset.copy()
    if (matrix.ndim == 1):
        _nd_image.zoom_shift(filtered, matrix, offset, output, order, mode, cval)
    else:
        _nd_image.geometric_transform(filtered, None, None, matrix, offset, output, order, mode, cval, None, None)
    return return_value
Apply an affine transformation.

The given matrix and offset are used to find for each point in the
output the corresponding coordinates in the input by an affine
transformation. The value of the input at those coordinates is
determined by spline interpolation of the requested order. Points
outside the boundaries of the input are filled according to the given
mode. The output shape can optionally be given. If not given it is
equal to the input shape. The parameter prefilter determines if the
input is pre-filtered before interpolation, if False it is assumed
that the input is already filtered.

The matrix must be two-dimensional or can also be given as a
one-dimensional sequence or array. In the latter case, it is
assumed that the matrix is diagonal. A more efficient algorithms
is then applied that exploits the separability of the problem.
def affine_transform(input, matrix, offset=0.0, output_shape=None, output_type=None, output=None, order=3, mode='constant', cval=0.0, prefilter=True):
    'Apply an affine transformation.\n\n    The given matrix and offset are used to find for each point in the\n    output the corresponding coordinates in the input by an affine\n    transformation. The value of the input at those coordinates is\n    determined by spline interpolation of the requested order. Points\n    outside the boundaries of the input are filled according to the given\n    mode. The output shape can optionally be given. If not given it is\n    equal to the input shape. The parameter prefilter determines if the\n    input is pre-filtered before interpolation, if False it is assumed\n    that the input is already filtered.\n\n    The matrix must be two-dimensional or can also be given as a\n    one-dimensional sequence or array. In the latter case, it is\n    assumed that the matrix is diagonal. A more efficient algorithms\n    is then applied that exploits the separability of the problem.\n    '
    if ((order < 0) or (order > 5)):
        raise RuntimeError('spline order not supported')
    input = numpy.asarray(input)
    if numpy.iscomplexobj(input):
        raise TypeError('Complex type not supported')
    if (output_shape is None):
        output_shape = input.shape
    if ((input.ndim < 1) or (len(output_shape) < 1)):
        raise RuntimeError('input and output rank must be > 0')
    mode = _extend_mode_to_code(mode)
    if (prefilter and (order > 1)):
        filtered = spline_filter(input, order, output=numpy.float64)
    else:
        filtered = input
    (output, return_value) = _ni_support._get_output(output, input, output_type, shape=output_shape)
    matrix = numpy.asarray(matrix, dtype=numpy.float64)
    if ((matrix.ndim not in [1, 2]) or (matrix.shape[0] < 1)):
        raise RuntimeError('no proper affine matrix provided')
    if (matrix.shape[0] != input.ndim):
        raise RuntimeError('affine matrix has wrong number of rows')
    if ((matrix.ndim == 2) and (matrix.shape[1] != output.ndim)):
        raise RuntimeError('affine matrix has wrong number of columns')
    if (not matrix.flags.contiguous):
        matrix = matrix.copy()
    offset = _ni_support._normalize_sequence(offset, input.ndim)
    offset = numpy.asarray(offset, dtype=numpy.float64)
    if ((offset.ndim != 1) or (offset.shape[0] < 1)):
        raise RuntimeError('no proper offset provided')
    if (not offset.flags.contiguous):
        offset = offset.copy()
    if (matrix.ndim == 1):
        _nd_image.zoom_shift(filtered, matrix, offset, output, order, mode, cval)
    else:
        _nd_image.geometric_transform(filtered, None, None, matrix, offset, output, order, mode, cval, None, None)
    return return_value