pyewt.ewt2dwatershed module
- pyewt.ewt2dwatershed.ewt2d_watershed(f, params)[source]
Compute the 2D EWT based on a Watershed partitioning of the Fourier domain.
- Parameters:
f (2D ndarray) – Input image.
params (dict) – Transform parameters.
- Returns:
ewtw (list of 2D ndarray) – Collection of outputs of each EW filter.
mfb (list of 2D ndarray) – The built filter bank.
maxima (ndarray) – Coordinates of each meaningful detected maxima.
waterpartition (2D ndarray) – Detected Voronoi partition.
plane (ndarray) – Scale-space domain.
Notes
If params[“log”] is set to True, then the detection is performed on the logarithm of the spectrum of f. 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). params[“tau”]: is the half width of the transition area for the Voronoi partition (0.1 is a good default value). params[“complex”]: if 1, the watershed partition is complex, otherwise it is real (0 is real).
Though usually not providing better results, this function allows regularization of the spectrum of 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 (07/28/2025)
- pyewt.ewt2dwatershed.iewt2d_watershed(ewtw, mfb)[source]
Performs the inverse Empirical Watershed Wavelet Transform, returning a reconstruction of the image.
- Parameters:
ewtw (list of 2D ndarray) – Empirical wavelet coefficients.
mfb (list of 2D ndarray) – Corresponding empirical wavelet filters.
- Returns:
rec (2D ndarray) – Reconstructed image.
Author (Jerome Gilles)
Institution (San Diego State University)
Version (1.0 (07/28/2025))
- pyewt.ewt2dwatershed.show_ewt2d_watershed_boundaries(f, wat, color=None, logspec=0)[source]
Plots the edges of the watershed partition onto the magnitude of the Fourier spectrum of the input image.
- Parameters:
f – ndarray Input image.
wat – ndarray Watershed partition image (same size as f).
color – list or tuple RGB color for the partition edges, values in [0,1]. Default is red.
logspec – int If 1, plot the logarithm of the spectrum. Default is 0.
Author: Jerome Gilles Institution: San Diego State University Version: 1.0 (07/28/2025)