golconda.adjustl1 module

golconda.adjustl1.adjust_map_l1(input_image, mask, targetvalues, density=False)[source]

Adjusts wavelet coefficients of an input image to match the target histogram and L1 norm per bin.

Parameters: - input_image (2D array): Input wavelet coefficient map for a given scale. - mask (2D array): Boolean mask indicating which coefficients should be modified. - targetvalues (dict): Dictionary containing target statistics:

  • ‘histogram’ (1D array): Target histogram (normalized to sum to 1).

  • ‘binedges’ (1D array): Bin edges.

  • ‘l1_norm’ (1D array): Target L1 norm per bin.

  • ‘bincenters’ (1D array): Bin centers.

Returns: - adjusted_image (2D array): Adjusted wavelet coefficient map.

golconda.adjustl1.adjust_pixel_values(image, mask, targetvalues, density=False)[source]

Adjusts the pixel values of an image based on target statistics.

Parameters:
  • image (ndarray) – The input image.

  • mask (ndarray) – The mask indicating valid pixels.

  • targetvalues (dict) – The target statistics including ‘binedges’, ‘histogram’, and ‘l1_norm’.

  • density (bool, optional) – Flag indicating whether to use density scaling. Defaults to False.

Returns:

The adjusted image. float: The total error normalized by the maximum L1 norm target.

Return type:

ndarray

golconda.adjustl1.calculate_histogram_l1norm(image, mask, nbins, density=False)[source]

Calculates the histogram and L1 norm of an image while accounting for a mask.

Parameters:
  • image (np.ndarray) – The input image.

  • mask (np.ndarray) – The mask to apply on the image (1 for valid pixels, 0 to ignore).

  • nbins (int or array-like) – Number of bins or bin edges for the histogram.

  • density (bool) – Whether to compute a density-normalized histogram.

Returns:

The edges of the bins. bincenters (np.ndarray): The center of each bin. hist (np.ndarray): The histogram values for each bin. bin_l1_norm (list): The L1 norm for each bin.

Return type:

binedges (np.ndarray)

golconda.adjustl1.process_image(target, filter_type, nscales, nbins, decomposer_class, density=False)[source]

Process the target map to compute wavelet coefficients, histograms, L1 norms, and power spectrum.

Parameters:
  • target (np.ndarray) – The input map to analyze.

  • filter_type (str) – The type of filter to use for wavelet decomposition.

  • nscales (int) – The number of scales for decomposition.

  • nbins (list[int]) – Number of bins for the histogram at each scale.

  • pixelsize (float) – Pixel size for power spectrum adjustment.

  • adjuster_class – A class implementing compute_power_spectrum().

  • decomposer_class – A class implementing decompose().

Returns:

A dictionary containing wavelet coefficient statistics and power spectrum information.

Return type:

dict