# pyewt.ewt2dcurvelet module

pyewt.ewt2dcurvelet.ewt2d_angular_sector(theta, radius, theta0, theta1, r0, r1, gammaw, Dtheta)

  Build curvelet filter on a given angular sector

  Parameters:

    - theta (-) – Angles at each pixel of the polar grid corresponding to the image

    - radius (-) – Radius at each pixel of the polar grid corresponding to the image

    - theta0 (-)

    - theta1 (angles defining the angular edges (must have theta0 < theta1))

    - r0 (-)

    - r1

    - pi) (radius defining the edges of the angular sector (must have r0 < r1 <=)

    - gammaw (-)

    - Dtheta (-)

    - Returns

    - angular (-) – Matrix containing the curvelet filter

  Notes

  This function creates the curvelet filter in the Fourier domain ((0,0) frequency being in the center of the image) which has a support defined in polar coordinates (r,angles) in

  > [(1-gammaw)r0,(1+gammaw)r1]x[theta0-Dtheta,theta1+Dtheta],

  and

    [(1-gammaw)r0,(1+gammaw)r1]x[theta0-Dtheta+pi,theta1+Dtheta+pi],

  respectively.

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

pyewt.ewt2dcurvelet.ewt2d_create_polar_grid(W, H)

  Create the polar coordinates

  Parameters:

    - W (-)

    - H (width and height of the image)

  Returns:

    - - theta (ndarray) – Angles at each pixel of the polar grid corresponding to the image

    - - radius (ndarray) – Radius at each pixel of the polar grid corresponding to the image

  Notes

  This function creates matrices containing the polar radius and angles (in [-pi, pi]) for each pixel (assuming that the position (0,0) is at the center of the image.

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

pyewt.ewt2dcurvelet.ewt2d_curvelet(f, params)

  2D empirical curvelet transform

  Parameters:

    - f (-) – input image (must be square)

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

  Returns:

    - - ewtc (list) – set of curvelet coefficients.

    - - mfb (list) – set of curvelet filters that were used to perform the forward transform.

    - - Bw (set of detected scales (see Notes below))

    - - Bt (set of detected angles (see Notes below))

  Notes

  This function performs the empirical curvelet transform on the square image f. Three options are available (set in params[“option”] as 1, 2 or 3):

  > 1. scales and angles are detected independently

  > 2. scales are detected first then the angular sector within each scale ring

  > 3. angles are detected first then the scales within each angular sector

  Note that the scaling function is always detect first before performing the above options.

  The options for detecting the scales and angles are set in params as: If params[“log”] is set to True, then the detection is performed on the logarithm of the spectrum of f.

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

  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.

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

  1. A global trend remover method is set via params[“curvpreproc”]:

       - “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[“curvdegree”] 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[“curvreg”]:

       - “none” : does nothing, returns f

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

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

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

           by params[“curvlengthfilter”]

       - “closing”applies the morphological closing operator of length

           given by params[“curvlengthfilter”]

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

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

  - “localmaxmin”select the lowest minima between consecutive

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

  - “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

  The ewtc and mfb are organized as follows: 1) (ewtc{1} are the lowpass coefficient (scaling function). For option 1 and 2, next are mfb{s}{t} are the coefficients where s corresponds to the scales and t to the direction; while for option 3 they are ordered as mfb{t}{s}. For mfb, all filters have been shifted back to have the (0,0) frequency in the upper left corner.

  For option 1 and 2, Bw is an array containing the set of scale boundaries, for option 3 it is a list where Bw[0] is the radius of the scaling function, the remaining Bw[k] are ndarray containing the list of scale radius per each angular sector.

  For option 1 and 3, Bt is an array contianing the set of angles boundaries, for option 2 it is a list where each Bt[k] is an ndarray containing the detected angles within each scale ring.

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

pyewt.ewt2dcurvelet.ewt2d_curvelet_filterbank(Bw, Bt, W, H, option=1)

  Build the empirical curvelet filter bank

  Parameters:

    - Bw (-) – list of radius boundaries (scales) normalized in [0,pi)

    - Bt (-) – list of angular boundaries normalized in [-3pi/4,pi/4]

    - W (-)

    - H (width and height of the image)

    - option (-) – wanted curvelet option used to detect Bw and Bt

  Returns:

    - mfb – set of filters

  Return type:

    list

  Notes

  The filter bank is organized as follows: 1) (mfb{1} is the lowpass filter (scaling function). For option 1 and 2, next are mfb{s}{t} are the bandpass filters where s corresponds to the scales and t to the direction; while for option 3 they are ordered as mfb{t}{s}. All filters have been shifted back to have the (0,0) frequency in the upper left corner.

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

pyewt.ewt2dcurvelet.ewt2d_curvelet_plot_comp(ewt, option, energy=False)

  Plot the empirical curvelet components

  Parameters:

    - ewt (-) – The first element is the scaling coefficient. The next elements are themselves lists containing the curvelet coefficients

    - option (-) – Type of empirical curvelets that was used in the transform

    - energy (-) – If True, the energy will be indicated above each image

    - Author (Jerome Gilles)

    - Institution (San Diego State University)

    - Version (1.0 (01/30/2025))

pyewt.ewt2dcurvelet.ewt2d_curvelet_plot_filters(mfb, option)

  Plot the empirical curvelet filters in the Fourier domain

  Parameters:

    - mfb (-) – The first element is the scaling filter. The next elements are themselves lists containing the curvelet filters

    - option (-) – Type of empirical curvelets that was used in the transform

    - Author (Jerome Gilles)

    - Institution (San Diego State University)

    - Version (1.0 (01/30/2025))

pyewt.ewt2dcurvelet.ewt2d_curvelet_scaling(radius, w1, gamma, W, H)

  Build the scaling function in the Fourier domain

  Parameters:

    - radius (-) – Radius at each pixel of the polar grid corresponding to the image

    - w1 (-)

    - gamma (-)

    - W (-)

    - H (width and height of the image)

  Returns:

    - yms – Matrix containing the scaling filter

  Return type:

    ndarray

  Notes

  Generate the 2D Littlewood-Paley wavelet 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/30/2025)

pyewt.ewt2dcurvelet.ewt_angles_detect(f, params)

  Detect the angular boundaries

  Parameters:

    - f (-) – 1D spectrum on which to perform the detection

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

  Returns:

    - boundaries – set of detected angles

  Return type:

    ndarray

  Notes

  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:

  1. A global trend remover method is set via params[“curvpreproc”]:

       - “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[“curvdegree”] 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[“curvreg”]:

       - “none” : does nothing, returns f

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

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

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

           by params[“curvlengthfilter”]

       - “closing”applies the morphological closing operator of length

           given by params[“curvlengthfilter”]

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

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

  - “localmaxmin”select the lowest minima between consecutive

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

  - “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

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

pyewt.ewt2dcurvelet.ewt_angles_locmax(f, N)

  Detect the midpoint between N largest maxima

  ## Parameter

  - f: ndarray

      1D spectrum on which to perform the detection

  - N: maximal number of largest maxima

  Returns - bounds: ndarray

  > set of detected midpoints

  Notes

  The minima are return as indices (not frequency).

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

pyewt.ewt2dcurvelet.ewt_angles_locmaxmin(f, N)

  Detect the lowest minima between N largest maxima

  ## Parameter

  - f: ndarray

      1D spectrum on which to perform the detection

  - N: maximal number of largest maxima

  Returns - bounds: ndarray

  > set of detected minima

  Notes

  The minima are return as indices (not frequency).

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

pyewt.ewt2dcurvelet.iewt2d_curvelet(ewtc, mfb)

  Inverse 2D empirical curvelet transform

  Parameters:

    - ewtc (-) – set of curvelet coefficients.

    - mfb (-) – set of curvelet filters that were used to perform the forward transform.

  Returns:

    - rec – reconstructed image (note it is of complex type)

  Return type:

    ndarray

  Notes

  Uses the formulation of the dual filter bank to perform the inverse transform.

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

pyewt.ewt2dcurvelet.plot_curvelet_sectors(f, BW, BT, option, logtag=True, title='Curvelet Fourier supports')

  Plot the rings delineating the curvelet supports

  Parameters:

    - f (-) – Input image

    - BW (-) – Array that contain the detected radius.

    - BT (-) – Array that contain the detected angle.

    - option (-) – Type of empirical curvelets that was used in the transform

    - 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 “Curvelet Fourier supports”.

  Notes

  This function plots the position of the detected curvelet supports in the Fourier domain.

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