pyewt.ewt2dtensor module

pyewt.ewt2dtensor.ewt2d_tensor(im, params)[source]

2D Tensor Empirical Wavelet Transform

Parameters:
  • f (ndarray) – input image

  • params (Dictionary) – must be set properly accordingly to the options described in the Notes section

Returns:

  • - ewtC (list) – 2-dimensional list containing each empirical wavelet coefficients

  • - mfbR (list) – each element of that list is a nparray containing the different filters to process the rows

  • - mfbC (list) – each element of that list is a nparray containing the different filters to process the columns

  • - BR (ndarray) – list of boundaries normalized in [0,pi) for the rows

  • - BC (ndarray) – list of boundaries normalized in [0,pi) for the columns

Notes

This function builds two sets of 1D empirical Littlewood-Paley wavelet filters to respectively process the rows and columns provided in params. It has three main steps: 1) detect the supports boundaries, 2) build the wavelet filter bank, 3) perform the transform itself. The options for steps 1) are described hereafter.

STEP 1): boundary detection: If params[“log”] is set to True, then the detection is performed on the logarithm of the spectrum of f.

Two types of preprocessing are available to “clean” the spectrum:

  1. A global trend remover method is set via params[“globtrend”]:
    • “none” : does nothing, returns f

    • “powerlaw”uses a power law to estimate the trend, returns

      f - powerlaw(f)

    • “polylaw”: uses a polynomial interpolation of degree specified
      by params[“degree”] to estimate the trend, returns

      f - polynomial(f)

    • “morpho”uses morphological operators, returns

      f - (opening(f)+closing(f))/2

    • “tophat”uses morphological operators, returns

      f - opening(f)

    • “opening”returns

      opening(f)

  2. A regularization method is set via params[“reg”]:
    • “none” : does nothing, returns f

    • “gaussian”convolve f with a Gaussian of length and standard

      deviation given by params[“lengthfilter”] and params[“sigmafilter”], respectively

    • “average”: convolve f with a constant filter of length given

      by params[“lengthfilter”]

    • “closing”applies the morphological closing operator of length

      given by params[“lengthfilter”]

The wanted boundary detection method must be set in params[“detect”]. The available options are: - “localmax” : select the mid-point between consecutive maxima.

params[“N”] must be set to the expected number of modes.

  • “localmaxmin”select the lowest minima between consecutive

    maxima of the preprocessed spectrum. params[“N”] must be set to the expected number of modes.

  • “localmaxminf”select the lowest minima between consecutive

    maxima where the minima are detected on the original spectrum instead of the preprocessed one. params[“N”] must be set to the expected number of modes.

  • “adaptivereg”this method re-adjust a set of provided initial

    boundaries based on the actual lowest minima of the preprocessed spectrum params[“InitBounds”] must be set with a vector of initial boundaries

  • “adaptive”this method re-adjust a set of provided initial

    boundaries based on the actual lowest minima of the original spectrum params[“InitBounds”] must be set with a vector of initial boundaries

  • “scalespace”uses the scale-space detection technique to

    automatically find the boundaries (including their number) params[“typeDetect”] must be set to the wanted classification method. The available options are: - “otsu” : uses Otsu’s technique - “halfnormal” : uses a half-normal law to model the problem - “empiricallaw” : uses the data itself to build a model of the problem - “mean” : threshold is fixed as the mean of the data - “kmeans” : uses kmeans to classify

For the automatic detection methods, a completion step is available is the number of detected modes is lower than an expected value params[“N”]. If needed, the last high frequency support is evenly splitted. This step is performed if params[“Completion”] is set to True.

Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/21/2025)

pyewt.ewt2dtensor.iewt2d_tensor(ewt, mfbR, mfbC)[source]

Inverse 2D Tensor Empirical Wavelet Transform

Parameters:
  • ewt (-) – 2-dimensional list containing each empirical wavelet coefficients

  • mfbR (-) – each element of that list is a nparray containing the different filters to process the rows

  • mfbC (-) – each element of that list is a nparray containing the different filters to process the columns

Returns:

reconstructed image

Return type:

  • 2D nparray

Notes

This function performs the inverse tensor 2D empirical wavelet transform. The returned image is of dtype complex, thus if you are expecting a real image, you need to take the real part of the returned image.

Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/21/2025)

pyewt.ewt2dtensor.plot_comp_tensor(ewt, energy=False, cpx=False)[source]

Plot empirical tensor wavelet coefficients

Parameters:

  • ewt: list

    2-dimensional list containing each empirical wavelet coefficients

  • energy: True or False (default)

    If True, the energy will be indicated above each image

  • cpx: True or False (default)

    Indicate if the expected EWT component should be considered real or complex (in the former, only the real parts will be plotted)

Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/21/2025)

pyewt.ewt2dtensor.plot_tensor_boundaries(f, BR, BC, logtag=True, title='Tensor Fourier supports')[source]

Plot the tensor empirical wavelet supports

Parameters:
  • f (-) – Input image

  • BR (-) – Arrays that contain the detected boundaries for rows and columns, respectively.

  • BC (ndarray) – Arrays that contain the detected boundaries for rows and columns, respectively.

  • logtag (-) – Indicate if the logarithm of the spectrum should be used for the background.

  • title (-) – Title to be plotted on the figure. The default title is “Tensor Fourier supports”.

Notes

This function plots the position of the detected boundaries in the Fourier domain. Each rectangle (with its symmetric) defines an empirical wavelet support.

Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/21/2025)