imfun.atrous

This module comprises functions for à trous wavelet transform and related utilities.

(Synonims: starlet transform, stationary wavelet transform, non-decimated wavelet transform)

Besides transform, there are utility functions to smooth input data, remove trends in data or enhance data by noise suppression.

Functions defined in this module:

imfun.atrous.DFoF(v, level=9, **kwargs)

Normalize v as v/v_0 - 1 for v_0 taken as approximation at given level

imfun.atrous.DFoSD(v, level=9, smooth=0, **kwargs)

Normalize v as (v-v_0)/\sigma for v_0 taken as approximation at given level and \sigma taken as an estimation of the noise standard deviation.

imfun.atrous.decompose(arr, *args, **kwargs)

Dispatcher on 1D, 2D or 3D data decomposition

imfun.atrous.decompose1d(sig, level, phi=<Mock name='mock.array()' id='140508896700432'>, dtype='float64')

1D stationary wavelet transform with B3-spline scaling function

Parameters:
  • sig : 1D array
  • level : level of decomposition
  • phi : low-pass filter kernel (B3-spline by default)
  • dtype : dtype of the output)
Returns:
array of wavelet details + last approximation
imfun.atrous.decompose1d_numpy(sig, level, phi=<Mock name='mock.array()' id='140508896700432'>, boundary='symm')

1D stationary wavelet transform with B3-spline scaling function

Parameters:
  • sig : 1D array

  • level : level of decomposition

  • phi : low-pass filter kernel (B3-spline by default)

  • boundary : boundary conditions (passed to scipy.signal.convolve2d, ‘symm’

    by default)

Returns:
list of wavelet details + last approximation
imfun.atrous.decompose1d_weave(sig, level, phi=<Mock name='mock.array()' id='140508896700432'>, dtype='float64')

1D stationary wavelet transform with B3-spline scaling function

Parameters:
  • sig : 1D array
  • level : level of decomposition
  • phi : low-pass filter kernel (B3-spline by default)
  • dtype : dtype of the output)
Returns:
array of wavelet details + last approximation
imfun.atrous.decompose2d(arr2d, level, phi=<Mock name='mock.array()' id='140508896700432'>, dtype='float64')

2D stationary wavelet transform with B3-spline scaling function

  • arr2d : 2D array
  • level : level of decomposition
  • phi : low-pass filter kernel (B3-spline by default)
  • dtype : dtype of the output)
array of wavelet details + last approximation
imfun.atrous.decompose2d_numpy(arr2d, level, phi=None, boundary='symm')

2D stationary wavelet transform with B3-spline scaling function

This is a convolution version, where kernel is zero-upsampled explicitly. Not fast.

Parameters:
  • arr2d : 2D array

  • level : level of decomposition

  • phi : low-pass filter kernel (B3-spline by default)

  • boundary : boundary conditions (passed to scipy.signal.convolve2d, ‘symm’

    by default)

Returns:
list of wavelet details + last approximation. Each element in the list is an image of the same size as the input image.
imfun.atrous.decompose2d_weave(arr2d, level, phi=<Mock name='mock.array()' id='140508896700432'>, dtype='float64')

2D stationary wavelet transform with B3-spline scaling function

  • arr2d : 2D array
  • level : level of decomposition
  • phi : low-pass filter kernel (B3-spline by default)
  • dtype : dtype of the output)
array of wavelet details + last approximation
imfun.atrous.decompose3d(arr, level=1, phi=<Mock name='mock.array()' id='140508896700432'>, curr_j=0, axis=None)

Semi-separable a trous wavelet decomposition for 3D data arrays with B3-spline scaling function

If arr is an array, then each arr[n] are treated as 2D images and arr[:,j,k] are treated as 1D signals. If axis is not None, only 1D decomposition along the first axis is done (considered as temporal domain).

Parameters:
  • arr : 3D array
  • level : level of decomposition
  • phi : low-pass filter kernel (B3-spline by default)
  • axis: if not None, only do 1D for decompositions along first axis
Returns:
list of wavelet details + last approximation. Each element in the list is a 3D array of the same size as the input array.
imfun.atrous.decompose3d_numpy(arr, level=1, phi=<Mock name='mock.array()' id='140508896700432'>, boundary1d='mirror', boundary2d='symm')

Semi-separable a trous wavelet decomposition for 3D data with B3-spline scaling function

If arr is an input array, then each arr[n] are treated as 2D images and arr[:,j,k] are treated as 1D signals.

Parameters:
  • arr : 3D array
  • level : level of decomposition
  • phi : low-pass filter kernel (B3-spline by default)
  • boundary1d : boundary conditions passed as mode to scipy.ndimage.convolve1d
  • boundary2d : boundary conditions passed to scipy.signal.convolve2d
Returns:
list of wavelet details + last approximation. Each element in the list is a 3D array of the same size as the input array.
imfun.atrous.decompose3d_weave(arr, level=1, phi=<Mock name='mock.array()' id='140508896700432'>, curr_j=0, axis=None)

Semi-separable a trous wavelet decomposition for 3D data arrays with B3-spline scaling function

If arr is an array, then each arr[n] are treated as 2D images and arr[:,j,k] are treated as 1D signals. If axis is not None, only 1D decomposition along the first axis is done (considered as temporal domain).

Parameters:
  • arr : 3D array
  • level : level of decomposition
  • phi : low-pass filter kernel (B3-spline by default)
  • axis: if not None, only do 1D for decompositions along first axis
Returns:
list of wavelet details + last approximation. Each element in the list is a 3D array of the same size as the input array.
imfun.atrous.detrend(arr, level=7, **kwargs)

Return a detrended representation of the input data by removing the aproximation at a given level.

imfun.atrous.estimate_sigma(arr, coefs=None, k=3, eps=0.01, max_iter=1000000000.0)

Estimate standard deviation of noise in data.

Parameters:
  • arr: input array
  • coefs: wavelet coefficients, if None, they will be calculated
  • k: threshold in \times noise S.D.
  • eps: tolerance
  • max_iter: maximum number of iterations allowed
Returns:
  • estimation of standard deviation (\sigma) as a number.
imfun.atrous.estimate_sigma_kclip(arr, k=3.0, max_iter=3)

Estimate standard deviation of noise in data using the K-clip algorithm.

imfun.atrous.estimate_sigma_mad(arr, is_details=False)

Estimate standard deviation of noise in data using median absolute difference (M.A.D) algorithm

Parameters:
  • arr: input array
  • is_details: if True, the input array is treated as wavelet coefficients at the first level of decomposition.
Returns:
  • estimation of standard deviation (\sigma) as a number.
imfun.atrous.loc_std(y)

local estimate of standard deviation of y

imfun.atrous.locations(shape)

Return all locations within shape as iterator

imfun.atrous.rec_atrous(coefs, level=None)

Reconstruct from a trous decomposition. Last coef is last approx

imfun.atrous.smooth(arr, level=1, **kwargs)

Return a smoothed representation of the input data by retaining only approximation at a given level.

imfun.atrous.wavelet_denoise(f, k=[3.5, 3.0, 2.5, 2.0], level=4, noise_std=None, modulus=False, soft=False)

Denoise input data through a trous wavelet transform.

Parameters:
  • f: input array (dimensions can be 1D, 2D or 3D)
  • k: (num or iterable) – threshold it \times noise S.D. If iterable, defines separate thresholds for different levels of decomposition
  • level: (num) – level of decomposition. If k is iterable, and its length is smaller than level, then it limits the decomposition leve
  • modulus: (bool) – if True, absolute values of coefficients are compared to the threshold
  • soft: (bool) – if `True, do “soft” thresholding
Returns:
  • a de-noised representation of the input data
imfun.atrous.zupsample(arr)

Upsample array by interleaving it with zero values