Module Expr Str ImportFrom alias alias Import alias identifier Assign NameStore Str FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Call NameLoad UnaryOpUSub NameLoad Num Return BinOpDiv NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice UnaryOpUSub NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Call NameLoad UnaryOpUSub NameLoad Num Return BinOpMult NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice UnaryOpUSub NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Call NameLoad UnaryOpUSub NameLoad Num Return BinOpDiv NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice UnaryOpUSub NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad keyword Call NameLoad UnaryOpUSub NameLoad Num Return BinOpMult NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice UnaryOpUSub NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad NameLoad Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad NameLoad Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Return Call NameLoad NameLoad Num keyword NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If CompareNotEq SubscriptLoad AttributeLoad NameLoad attr Index Num SubscriptLoad AttributeLoad NameLoad attr Index Num body Return BinOpSub BinOpMult Num Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpPow Call AttributeLoad NameLoad attr NameLoad Num keyword Num keyword Num Call AttributeLoad NameLoad attr BinOpPow Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Ellipsis Index Num Num keyword Num orelse Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpPow Call AttributeLoad NameLoad attr NameLoad Num keyword Num keyword Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If UnaryOpNot NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index Call NameLoad ListComp Call NameLoad Num NameLoad comprehension NameStore AttributeLoad NameLoad attr NameLoad For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body If CompareGtE NameLoad BinOpSub AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword UnaryOpUSub Call NameLoad Call AttributeLoad NameLoad attr BinOpDiv NameLoad Num keyword NameLoad If NameLoad body Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Call NameLoad UnaryOpUSub NameLoad Num orelse Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Call NameLoad UnaryOpUSub NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMult ListLoad Num NameLoad For NameStore Call NameLoad NameLoad body Assign NameStore Call NameLoad BinOpAdd BinOpAdd BinOpMult ListLoad Call NameLoad Num Num NameLoad ListLoad Call NameLoad NameLoad BinOpMult ListLoad Call NameLoad Num Num BinOpSub BinOpSub NameLoad NameLoad Num Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad Call AttributeLoad NameLoad attr ListLoad Num Num Num attr ListComp IfExp CompareEq NameLoad NameLoad Num Num comprehension NameStore Call NameLoad NameLoad Assign SubscriptStore NameLoad Index BinOpMult ListLoad Call NameLoad Num Num NameLoad BinOpMult Num NameLoad Return TupleLoad Call NameLoad NameLoad NameLoad keyword NameLoad NameLoad decorator_list
N/A N/A Function of unitary fourier transform and utilities

This module implements the unitary fourier transform, also known as
the ortho-normal transform. It is especially useful for convolution
[1], as it respects the Parseval equality. The value of the null
frequency is equal to

.. math::  rac{1}{\sqrt{n}} \sum_i x_i

so the Fourier transform has the same energy as the original image
(see ``image_quad_norm`` function). The transform is applied from the
last axis for performance (assuming a C-order array input).

References
----------
.. [1] B. R. Hunt "A matrix theory proof of the discrete convolution
       theorem", IEEE Trans. on Audio and Electroacoustics,
       vol. au-19, no. 4, pp. 285-288, dec. 1971

 __future__ division print_function N/A numpy np N/A __keywords__ fft, Fourier Transform, orthonormal, unitary ufftn N/A N/A inarray dim N/A None N/A N/A N-dimensional unitary Fourier transform.

    Parameters
    ----------
    inarray : ndarray
        The array to transform.
    dim : int, optional
        The last axis along which to compute the transform. All
        axes by default.

    Returns
    -------
    outarray : ndarray (same shape than inarray)
        The unitary N-D Fourier transform of ``inarray``.

    Examples
    --------
    >>> input = np.ones((3, 3, 3))
    >>> output = ufftn(input)
    >>> np.allclose(np.sum(input) / np.sqrt(input.size), output[0, 0, 0])
    True
    >>> output.shape
    (3, 3, 3)
     N/A N/A dim None N/A N/A dim N/A inarray ndim N/A outarray N/A N/A N/A np fft fftn inarray axes N/A range N/A dim 0 N/A N/A outarray N/A N/A np sqrt N/A N/A np prod N/A N/A inarray shape N/A N/A dim N/A uifftn N/A N/A inarray dim N/A None N/A N/A N-dimensional unitary inverse Fourier transform.

    Parameters
    ----------
    inarray : ndarray
        The array to transform.
    dim : int, optional
        The last axis along which to compute the transform. All
        axes by default.

    Returns
    -------
    outarray : ndarray (same shape than inarray)
        The unitary inverse N-D Fourier transform of ``inarray``.

    Examples
    --------
    >>> input = np.ones((3, 3, 3))
    >>> output = uifftn(input)
    >>> np.allclose(np.sum(input) / np.sqrt(input.size), output[0, 0, 0])
    True
    >>> output.shape
    (3, 3, 3)
     N/A N/A dim None N/A N/A dim N/A inarray ndim N/A outarray N/A N/A N/A np fft ifftn inarray axes N/A range N/A dim 0 N/A N/A outarray N/A N/A np sqrt N/A N/A np prod N/A N/A inarray shape N/A N/A dim N/A urfftn N/A N/A inarray dim N/A None N/A N/A N-dimensional real unitary Fourier transform.

    This transform considers the Hermitian property of the transform on
    real-valued input.

    Parameters
    ----------
    inarray : ndarray, shape (M, N, ..., P)
        The array to transform.
    dim : int, optional
        The last axis along which to compute the transform. All
        axes by default.

    Returns
    -------
    outarray : ndarray, shape (M, N, ..., P / 2 + 1)
        The unitary N-D real Fourier transform of ``inarray``.

    Notes
    -----
    The ``urfft`` functions assume an input array of real
    values. Consequently, the output has a Hermitian property and
    redundant values are not computed or returned.

    Examples
    --------
    >>> input = np.ones((5, 5, 5))
    >>> output = urfftn(input)
    >>> np.allclose(np.sum(input) / np.sqrt(input.size), output[0, 0, 0])
    True
    >>> output.shape
    (5, 5, 3)
     N/A N/A dim None N/A N/A dim N/A inarray ndim N/A outarray N/A N/A N/A np fft rfftn inarray axes N/A range N/A dim 0 N/A N/A outarray N/A N/A np sqrt N/A N/A np prod N/A N/A inarray shape N/A N/A dim N/A uirfftn N/A N/A inarray dim shape N/A None None N/A N/A N-dimensional inverse real unitary Fourier transform.

    This transform considers the Hermitian property of the transform
    from complex to real input.

    Parameters
    ----------
    inarray : ndarray
        The array to transform.
    dim : int, optional
        The last axis along which to compute the transform. All
        axes by default.
    shape : tuple of int, optional
        The shape of the output. The shape of ``rfft`` is ambiguous in
        case of odd-valued input shape. In this case, this parameter
        should be provided. See ``np.fft.irfftn``.

    Returns
    -------
    outarray : ndarray
        The unitary N-D inverse real Fourier transform of ``inarray``.

    Notes
    -----
    The ``uirfft`` function assumes that the output array is
    real-valued. Consequently, the input is assumed to have a Hermitian
    property and redundant values are implicit.

    Examples
    --------
    >>> input = np.ones((5, 5, 5))
    >>> output = uirfftn(urfftn(input), shape=input.shape)
    >>> np.allclose(input, output)
    True
    >>> output.shape
    (5, 5, 5)
     N/A N/A dim None N/A N/A dim N/A inarray ndim N/A outarray N/A N/A N/A np fft irfftn inarray shape axes N/A range N/A dim 0 N/A N/A outarray N/A N/A np sqrt N/A N/A np prod N/A N/A outarray shape N/A N/A dim N/A ufft2 N/A N/A inarray N/A N/A N/A 2-dimensional unitary Fourier transform.

    Compute the Fourier transform on the last 2 axes.

    Parameters
    ----------
    inarray : ndarray
        The array to transform.

    Returns
    -------
    outarray : ndarray (same shape as inarray)
        The unitary 2-D Fourier transform of ``inarray``.

    See Also
    --------
    uifft2, ufftn, urfftn

    Examples
    --------
    >>> input = np.ones((10, 128, 128))
    >>> output = ufft2(input)
    >>> np.allclose(np.sum(input[1, ...]) / np.sqrt(input[1, ...].size),
    ...             output[1, 0, 0])
    True
    >>> output.shape
    (10, 128, 128)
     N/A N/A ufftn inarray 2 N/A uifft2 N/A N/A inarray N/A N/A N/A 2-dimensional inverse unitary Fourier transform.

    Compute the inverse Fourier transform on the last 2 axes.

    Parameters
    ----------
    inarray : ndarray
        The array to transform.

    Returns
    -------
    outarray : ndarray (same shape as inarray)
        The unitary 2-D inverse Fourier transform of ``inarray``.

    See Also
    --------
    uifft2, uifftn, uirfftn

    Examples
    --------
    >>> input = np.ones((10, 128, 128))
    >>> output = uifft2(input)
    >>> np.allclose(np.sum(input[1, ...]) / np.sqrt(input[1, ...].size),
    ...             output[0, 0, 0])
    True
    >>> output.shape
    (10, 128, 128)
     N/A N/A uifftn inarray 2 N/A urfft2 N/A N/A inarray N/A N/A N/A 2-dimensional real unitary Fourier transform

    Compute the real Fourier transform on the last 2 axes. This
    transform considers the Hermitian property of the transform from
    complex to real-valued input.

    Parameters
    ----------
    inarray : ndarray, shape (M, N, ..., P)
        The array to transform.

    Returns
    -------
    outarray : ndarray, shape (M, N, ..., 2 * (P - 1))
        The unitary 2-D real Fourier transform of ``inarray``.

    See Also
    --------
    ufft2, ufftn, urfftn

    Examples
    --------
    >>> input = np.ones((10, 128, 128))
    >>> output = urfft2(input)
    >>> np.allclose(np.sum(input[1,...]) / np.sqrt(input[1,...].size),
    ...             output[1, 0, 0])
    True
    >>> output.shape
    (10, 128, 65)
     N/A N/A urfftn inarray 2 N/A uirfft2 N/A N/A inarray shape N/A None N/A N/A 2-dimensional inverse real unitary Fourier transform.

    Compute the real inverse Fourier transform on the last 2 axes.
    This transform considers the Hermitian property of the transform
    from complex to real-valued input.

    Parameters
    ----------
    inarray : ndarray, shape (M, N, ..., P)
        The array to transform.

    Returns
    -------
    outarray : ndarray, shape (M, N, ..., 2 * (P - 1))
        The unitary 2-D inverse real Fourier transform of ``inarray``.

    See Also
    --------
    urfft2, uifftn, uirfftn

    Examples
    --------
    >>> input = np.ones((10, 128, 128))
    >>> output = uirfftn(urfftn(input), shape=input.shape)
    >>> np.allclose(input, output)
    True
    >>> output.shape
    (10, 128, 128)
     N/A N/A uirfftn inarray 2 shape shape N/A image_quad_norm N/A N/A inarray N/A N/A N/A Return the quadratic norm of images in Fourier space.

    This function detects whether the input image satisfies the
    Hermitian property.

    Parameters
    ----------
    inarray : ndarray
        Input image. The image data should reside in the final two
        axes.

    Returns
    -------
    norm : float
        The quadratic norm of ``inarray``.

    Examples
    --------
    >>> input = np.ones((5, 5))
    >>> image_quad_norm(ufft2(input)) == np.sum(np.abs(input)**2)
    True
    >>> image_quad_norm(ufft2(input)) == image_quad_norm(urfft2(input))
    True
     N/A N/A N/A N/A inarray shape N/A -1 N/A N/A inarray shape N/A -2 N/A N/A N/A N/A 2 N/A N/A np sum N/A N/A np sum N/A N/A N/A np abs inarray 2 axis -1 axis -1 N/A N/A np sum N/A N/A N/A np abs N/A inarray N/A N/A N/A 0 2 axis -1 N/A N/A N/A N/A np sum N/A N/A np sum N/A N/A N/A np abs inarray 2 axis -1 axis -1 N/A ir2tf N/A N/A imp_resp shape dim is_real N/A None True N/A N/A Compute the transfer function of an impulse response (IR).

    This function makes the necessary correct zero-padding, zero
    convention, correct fft2, etc... to compute the transfer function
    of IR. To use with unitary Fourier transform for the signal (ufftn
    or equivalent).

    Parameters
    ----------
    imp_resp : ndarray
        The impulse responses.
    shape : tuple of int
        A tuple of integer corresponding to the target shape of the
        transfer function.
    dim : int, optional
        The last axis along which to compute the transform. All
        axes by default.
    is_real : boolean (optional, default True)
       If True, imp_resp is supposed real and the Hermitian property
       is used with rfftn Fourier transform.

    Returns
    -------
    y : complex ndarray
       The transfer function of shape ``shape``.

    See Also
    --------
    ufftn, uifftn, urfftn, uirfftn

    Examples
    --------
    >>> np.all(np.array([[4, 0], [0, 0]]) == ir2tf(np.ones((2, 2)), (2, 2)))
    True
    >>> ir2tf(np.ones((2, 2)), (512, 512)).shape == (512, 257)
    True
    >>> ir2tf(np.ones((2, 2)), (512, 512), is_real=False).shape == (512, 512)
    True

    Notes
    -----
    The input array can be composed of multiple-dimensional IR with
    an arbitrary number of IR. The individual IR must be accessed
    through the first axes. The last ``dim`` axes contain the space
    definition.
     N/A N/A dim N/A N/A dim N/A imp_resp ndim N/A irpadded N/A N/A np zeros shape N/A N/A irpadded N/A N/A tuple N/A N/A slice 0 s N/A s N/A imp_resp shape imp_resp N/A N/A axis axis_size N/A enumerate N/A imp_resp shape N/A N/A N/A axis N/A N/A imp_resp ndim dim N/A N/A irpadded N/A N/A np roll irpadded shift N/A N/A int N/A N/A np floor N/A axis_size 2 axis axis N/A is_real N/A N/A N/A N/A N/A np fft rfftn irpadded axes N/A range N/A dim 0 N/A N/A N/A N/A N/A np fft fftn irpadded axes N/A range N/A dim 0 N/A laplacian N/A N/A ndim shape is_real N/A True N/A N/A Return the transfer function of the Laplacian.

    Laplacian is the second order difference, on row and column.

    Parameters
    ----------
    ndim : int
        The dimension of the Laplacian.
    shape : tuple, shape
        The support on which to compute the transfer function
    is_real : boolean (optional, default True)
       If True, imp_resp is assumed to be real-valued and
       the Hermitian property is used with rfftn Fourier transform
       to return the transfer function.

    Returns
    -------
    tf : array_like, complex
        The transfer function.
    impr : array_like, real
        The Laplacian.

    Examples
    --------
    >>> tf, ir = laplacian(2, (32, 32))
    >>> np.all(ir == np.array([[0, -1, 0], [-1, 4, -1], [0, -1, 0]]))
    True
    >>> np.all(tf == ir2tf(ir, (32, 32)))
    True
     N/A impr N/A N/A np zeros N/A N/A 3 ndim N/A dim N/A range ndim N/A N/A idx N/A tuple N/A N/A N/A N/A N/A slice 1 2 dim N/A N/A slice None N/A N/A N/A slice 1 2 N/A N/A ndim dim 1 N/A N/A impr N/A idx N/A N/A N/A N/A np array N/A -1.0 0.0 -1.0 reshape N/A N/A N/A i dim -1 1 N/A i N/A range ndim N/A N/A impr N/A N/A N/A N/A slice 1 2 ndim N/A 2.0 ndim N/A N/A N/A ir2tf impr shape is_real is_real impr N/A