operators module

Implements high level interface to manipulate linear operators. This module is not required by Q-MM, is basic, but can serve as guide or for reuse.

dft2(obj)

Return the orthogonal real 2D fft.

Parameters

obj (array-like) – The array on which to perform the 2D DFT.

Returns

out

Return type

array

Notes

This function is a wrapper of numpy.fft.rfft2. The DFT is made on the two last axis.

idft2(obj, shape)

Return the orthogonal real 2D ifft.

Parameters
  • obj (array-like) – The array on which to perform the inverse 2D DFT.

  • shape (tuple) – The output shape.

Returns

out

Return type

array

Notes

This function is a wrapper of numpy.fft.irfft2. The DFT is made on the two last axis.

class Operator

An abstract base class for linear operators.

abstract forward(point)

Return H·x

abstract adjoint(point)

Return Hᵀ·e

fwback(point)

Return HᵀH·x

T(point)

Return Hᵀ·e

class Conv2(ir, shape)

2D convolution on image.

Does not suppose periodic or circular condition.

imp_resp

The impulse response.

Type

array

shape

The shape of the input image.

Type

tuple of int

freq_resp

The frequency response of shape shape.

Type

array

Notes

Use fft internally for fast computation. The forward methods is equivalent to convolve2d with “valid” boudary condition and adjoint is equivalent to convolve2d with “full” boundary condition with zero filling.

__init__(ir, shape)

2D convolution on image.

Parameters
  • ir (array) – The impulse response.

  • shape (tuple of int) – The shape of the input image.

forward(point)

Return H·x

adjoint(point)

Return Hᵀ·e

fwback(point)

Return HᵀH·x

class Diff(axis)

Difference operator.

Compute the first-order differences along an axis.

axis

The axis along which the differences is performed.

Type

int

Notes

Use numpy.diff and implement the correct adjoint, with numpy.diff also.

__init__(axis)

First-order differences operator.

Parameters

axis (int) – the axis along which to perform the diff.

response(ndim)

Return the equivalent impulse response.

The result of forward method is equivalent with “valid” convolution with this impulse response. The adjoint operator corresponds the “full” convolution with the flipped impulse response.

freq_response(ndim, shape)

The frequency response.

forward(point)

Return H·x

adjoint(point)

Return Hᵀ·e

ir2fr(imp_resp, shape, center=None, real=True)

Return the frequency response from impulse responses.

This function make the necessary correct zero-padding, zero convention, correct DFT etc. to compute the frequency response from impulse responses (IR).

The IR array is supposed to have the origin in the middle of the array.

The Fourier transform is performed on the last len(shape) dimensions.

Parameters
  • imp_resp (array) – The impulse responses.

  • shape (tuple of int) – A tuple of integer corresponding to the target shape of the frequency responses, without hermitian property. len(shape) >= ndarray.ndim. The DFT is performed on the len(shape) last axis of ndarray.

  • center (tuple of int, optional) – The origin index of the impulse response. The middle by default.

  • real (boolean, optional) – If True, imp_resp is supposed real, the hermitian property is used with rfftn DFT and the output has shape[-1] / 2 + 1 elements on the last axis.

Returns

out – The frequency responses of shape shape on the last len(shape) dimensions.

Return type

array

Notes

  • The output is returned as C-contiguous array.

  • For convolution, the result have to be used with unitary discrete Fourier transform for the signal (norm=”ortho” of fft).

  • DFT are always performed on last axis for efficiency (C-order array).