pyewt.boundaries2d module
- pyewt.boundaries2d.UnSymmetrize_Fourier(in_array, extH, extW)[source]
Removes the extension of the spectrum that was introduced to symmetrize the spectrum.
- Parameters:
in_array (ndarray) – Magnitude of the spectrum to unsymmetrize.
extH (bool or int) – 1 (or True) if there is vertical extension, 0 otherwise.
extW (bool or int) – 1 (or True) if there is horizontal extension, 0 otherwise.
- Returns:
usym (ndarray) – Spectrum with original size.
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (07/15/2025))
- pyewt.boundaries2d.ewt2d_EmpiricalLaw(histo)[source]
Classifies minima curve lengths into two classes using an empirical law.
- Parameters:
L (1D ndarray) – Set of minima curve lengths.
ind (2D ndarray) – Original index of each minima (shape: [n_minima, 2]).
- Returns:
bounds (ndarray) – Detected bounds (subset of ind).
th (float) – Detected scale threshold.
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (07/15/2025))
- pyewt.boundaries2d.ewt2d_HalfNormalLaw(L, Lmax)[source]
Classifies minima curve lengths into two classes using a half-normal law.
- Parameters:
L (1D ndarray) – Set of minima curve lengths.
ind (2D ndarray) – Original index of each minima (shape: [n_minima, 2]).
Lmax (float) – Maximum possible length of a minima curve.
- Returns:
bounds (ndarray) – Detected bounds (subset of ind).
th (float) – Detected scale threshold.
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (07/15/2025))
- pyewt.boundaries2d.ewt2d_OtsuMethod(histo)[source]
Classifies the set of minima curve lengths stored in histo into two classes using Otsu’s method. Returns the boundaries which are supposed to be the meaningful ones.
- Parameters:
histo (ndarray) – Set of minima curve lengths (1D array).
- Returns:
bounds (ndarray) – Detected bounds (subset of ind).
th (int) – Detected scale threshold.
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (07/05/2025))
- pyewt.boundaries2d.ewt2d_fourier_extend(f, n)[source]
Extend image by periodization
- Parameters:
f (-) – image to extend
n (-)
- Returns:
- fe – extended image
- Return type:
ndarray
Notes
This function extend the provided image f by periodization on a strip of width n around the image
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (02/11/2025)
- pyewt.boundaries2d.ewt2d_fourier_shrink(f, n)[source]
shrink image
- Parameters:
f (-) – image to extend
n (-)
- Returns:
- fe – shrinked image
- Return type:
ndarray
Notes
This function shrinks the provided image f by removing a strip of width n around the image
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (02/11/2025)
- pyewt.boundaries2d.ewt2d_get_maxima(absff, params, extH, extW)[source]
Build a scale-space representation and post-process detected maxima. Discards maxima near the edge and, if needed, the center.
- Parameters:
absff (2D ndarray) – Input image (Fourier spectrum).
params (dict) – Empirical wavelet parameters (see Notes below).
extH (int) – 1 if height was extended, 0 otherwise.
extW (int) – 1 if width was extended, 0 otherwise.
- Returns:
centers (ndarray) – Coordinates of significant maxima.
plane (ndarray) – Scale-space plane.
Notes
- 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 - “kmeans” : uses kmeans to classify
params[“t”]: is the initial scale for the Gaussian kernel (0.8 is a good default value). params[“kn”]: is the kernel size for the Gaussian kernel (6 is a good default value). params[“niter”]: is the number of iterations through the scales (4 is a good default value). params[“edge”]: is the size (in pixels) of the strip to ignore at the edge of the image (0 is no strip). params[“includeCenter”]: if 1, the center of the image is included in the scale space maxima (0 is not included).
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (07/15/2025)
- pyewt.boundaries2d.ewt2d_gss(f, params)[source]
Build a 2D Gaussian scale space and detect local maxima.
- Parameters:
f (2D ndarray) – Input image (Fourier spectrum).
params (dict) – Parameters for the scale space and maxima detection (see Notes below).
- Returns:
worm_bound (ndarray) – Coordinates of the detected maxima.
Th (float) – Threshold for maxima detection.
plane (ndarray) – Scale-space plane.
Notes
- 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 - “kmeans” : uses kmeans to classify
params[“t”]: is the initial scale for the Gaussian kernel (0.8 is a good default value). params[“kn”]: is the kernel size for the Gaussian kernel (6 is a good default value). params[“niter”]: is the number of iterations through the scales (4 is a good default value).
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (07/21/2025)
- pyewt.boundaries2d.ewt2d_kmeansdetect(L)[source]
Detect meaningful minima using kmeans (for 1D L).
- Parameters:
L (1D ndarray) – Vector of the length of the minima curves.
- Returns:
th (float) – Detected scale threshold.
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (07/15/2025))
- pyewt.boundaries2d.ewt2d_localmax(f)[source]
Find local maxmima on a 2D image
- Parameters:
f (-) – image on which to perform the detection.
- Returns:
- tag (ndarray) – image with pixels either at 0 or 1 where 1 means a local maximum has been detected.
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (02/11/2025))
- pyewt.boundaries2d.ewt2d_plot_ssplane(plane)[source]
Plot 3D scale-space
- Parameters:
matrix (- plane DOK sparse) – contains the 3D scale-space domain
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (02/11/2025))
- pyewt.boundaries2d.ewt2d_spectrum_regularize(f, params)[source]
2D Spectrum regularization
- Parameters:
f (ndarray) – matrix containing the spectrum
params (Dictionary) – must have params[“reg”] to be set to one of the methods listed below must have params[“lengthfilter”] to be set for all methods must have params[“sigmafilter”] to be set to the standard deviation for the Gaussian method
- Returns:
ff – matrix containing the regularized spectrum
- Return type:
ndarray
Notes
This function regularizes f using the selected method set in params[“reg”]. The available methods are: - “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”]
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (02/09/2025)
- pyewt.boundaries2d.plot_scalespace_maxima(f, maxima, logtag=True, title='Scale-space Maxima', radius=1)[source]
Plot the scale-space maxima on the Fourier spectrum
- Parameters:
f (-) – Input image
maxima (-) – Arrays that contain the coordinates of the detected maxima in the Fourier domain.
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 “Scale-space Maxima”.
radius (-) – Radius of the maxima to be plotted in pixels. The default value is 1 pixel.
Notes
This function plots the position of the detected maxima in the Fourier domain via the scale-space method.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (07/15/2025)
- pyewt.boundaries2d.symmetrize_fourier(f)[source]
Symmetric extension of the Fourier spectrum
- Parameters:
f (ndarray) – input 2D Fourier spectrum
- Returns:
sym (ndarray) – symmetrized Fourier spectrum
extH (True/False) – indicate a vertical extension
extW (True/False) – indicate an horizontal extension
Notes
This function returns a symetrized Fourier spectrum by properly extending the expected directions. It returns a new spectrum where each dimension is odd.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (02/09/2025)