pyewt.ewt2dlp module
- pyewt.ewt2dlp.ewt2D_lp_scaling(w1, gamma, w, h)[source]
2D Littlewood-Paley scaling function
- Parameters:
w1 (-)
gamma (-)
w (-)
h (-)
- Returns:
- yms – filter corresponding to the scaling function
- Return type:
ndarray
Notes
Generate the 2D Littlewood-Paley scaling function in the Fourier domain associated to the disk [0,w1] with transition ratio gamma.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/24/2025)
- pyewt.ewt2dlp.ewt2d_lp(im, params)[source]
2D Littlewood-Paley Empirical Wavelet Transform
- Parameters:
im (ndarray) – input image
params (Dictionary) – must be set properly accordingly to the options described in the Notes section
- Returns:
- ewtlp (list) – 2-dimensional list containing each empirical wavelet coefficients
- mfb (list) – each element of that list is a ndarray containing the different filters
- BR (ndarray) – list of boundaries (radius) normalized in [0,pi)
Notes
This function builds the set of 2D empirical Littlewood-Paley wavelet filters based on parameters provided in params. It has three main steps: 1) detect the radius of each ring using the pseudo polar Fourier transform, 2) build the wavelet filter bank, 3) perform the transform itself. The options for steps 1) are described hereafter.
STEP 1): radius 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 f:
- 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)
- 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/24/2025)
- pyewt.ewt2dlp.ewt2d_lp_filterbank(boundaries, w, h)[source]
Build 2D Littlewood-Paley filterbank
- Parameters:
boundaries (-) – contains the list of detected boundaries (radius)
w (-)
h (width and height of the image, respectively.)
- Returns:
- mfb – each element of that list is a ndarray containing the different filters.
- Return type:
list
Notes
This function generate the 2D Littlewood-Paley filter bank (scaling function + wavelets) corresponding to the provided set of frequency rings.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/24/2025)
- pyewt.ewt2dlp.ewt2d_lp_up_wavelet(wn, gamma, w, h)[source]
2D Littlewood-Paley wavelet (highest frequencies)
- Parameters:
wn (-)
gamma (-)
w (-)
h (-)
- Returns:
- ymw – filter corresponding to the scaling function
- Return type:
ndarray
Notes
Generate the 2D Littlewood-Paley wavelet in the Fourier domain associated to the region above the radius wn with transition ratio gamma.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/24/2025)
- pyewt.ewt2dlp.ewt2d_lp_wavelet(wn, wm, gamma, w, h)[source]
2D Littlewood-Paley wavelet
- Parameters:
wn (-)
wm (-)
gamma (-)
w (-)
h (-)
- Returns:
- ymw – filter corresponding to the scaling function
- Return type:
ndarray
Notes
Generate the 2D Littlewood-Paley wavelet in the Fourier domain associated to the ring [wn,wm] with transition ratio gamma.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/24/2025)
- pyewt.ewt2dlp.iewt2d_lp(ewt, mfb)[source]
Inverse 2D Littlewood-Paley Empirical Wavelet Transform
- Parameters:
ewt (-) – 2-dimensional list containing each empirical wavelet coefficients.
mfb (-) – list containing the filter bank used to obtain ewt.
- Return type:
Reconstructed image
Notes
This function performs the inverse 2D Littlewood-Paley EWT. Note that returned image is of complex type (you need to take its real part if you expect a real image)
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/24/2025)
- pyewt.ewt2dlp.plot_lp_comp(ewt, energy=False)[source]
Plot 2D empirical Littlewood-Paley 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
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/23/2025)
- pyewt.ewt2dlp.plot_lp_filterbank(mfb)[source]
Plot 2D empirical Littlewood-Paley filters
Parameters:
- mfb: list
list containing each Littlewood-Paley filter
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/24/2025)
- pyewt.ewt2dlp.plot_lp_rings(f, BR, logtag=True, title='Littlewood-Paley Fourier supports')[source]
Plot the rings delineating the Littlewood-Paley supports
- Parameters:
f (-) – Input image
BR (-) – Array that contain the detected radius.
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 “Littlewood-Paley Fourier supports”.
Notes
This function plots the position of the detected rings in the Fourier domain. Each ring defines an empirical wavelet support.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (01/24/2025)