scarlet.wavelet¶
- exception scarlet.wavelet.InputError(message)[source]¶
Bases:
Exception
Exception raised for errors in the input.
- Attributes:
expression – input expression in which the error occurred message – explanation of the error
- class scarlet.wavelet.Starlet(image, coefficients, generation, convolve2D)[source]¶
Bases:
object
A class used to create the Wavelet transform of a cube of images from the ‘a trou’ algorithm.
The transform is performed by convolving the image by a seed starlet: the transform of an all-zero image with its central pixel set to one. This requires 2-fold padding of the image and an odd pad shape. The fft of the seed starlet is cached so that it can be reused in the transform of other images that have the same shape.
- Attributes:
coefficients
Starlet coefficients
convolve2D
Filter used to create starlet coefficients
generation
The generation of the starlet transform
image
The real space image
norm
The norm of a convolved dirac
scales
Number of starlet scales
Methods
from_coefficients
(coefficients[, ...])Generate an image from a set of starlet coefficients
from_image
(image[, scales, generation, ...])Generate a set of starlet coefficients for an image
- property coefficients¶
Starlet coefficients
- property convolve2D¶
Filter used to create starlet coefficients
- static from_coefficients(coefficients, generation=2, convolve2D=None)[source]¶
Generate an image from a set of starlet coefficients
- Parameters:
- coefficients: array-like
The starlet coefficients used to generate the image
- generation: int
The generation of the starlet transform (either 1 or 2).
- convolve2D: array-like
The filter used to convolve the image and create the wavelets. When convolve2D is None this uses a cubic bspline.
- Returns:
- result: Starlet
The resulting Starlet that contains the image, starlet coefficients, as well as the parameters used to generate the image.
- static from_image(image, scales=None, generation=2, convolve2D=None)[source]¶
Generate a set of starlet coefficients for an image
- Parameters:
- image: array-like
The image that is converted into starlet coefficients
- scales: int
The number of starlet scales to use. If scales is None then the maximum number of scales is used. Note: this is the length of the coefficients-1, as in the notation of Starck et al. 2011.
- generation: int
The generation of the starlet transform (either 1 or 2).
- convolve2D: array-like
The filter used to convolve the image and create the wavelets. When convolve2D is None this uses a cubic bspline.
- Returns:
- result: Starlet
The resulting Starlet that contains the image, starlet coefficients, as well as the parameters used to generate the coefficients.
- property generation¶
The generation of the starlet transform
- property image¶
The real space image
- property norm¶
The norm of a convolved dirac
- property scales¶
Number of starlet scales
- scarlet.wavelet.apply_wavelet_denoising(image, sigma=None, k=3, epsilon=0.1, max_iter=20, image_type='ground', positive=True)[source]¶
Apply wavelet denoising
Uses the algorithm and notation from Starck et al. 2011, section 4.1
- Parameters:
- image: array-like
The image to denoise
- sigma: float
The standard deviation of the image
- k: float
The threshold in units of sigma to declare a coefficient significant
- epsilon: float
Convergence criteria for determining the support
- max_iter: int
The maximum number of iterations. This applies to both finding the support and the denoising loop.
- image_type: str
The type of image that is being used. This should be “ground” for ground based images with wide PSFs or “space” for images from space-based telescopes with a narrow PSF.
- positive: bool
Whether or not the expected result should be positive
- Returns:
- result: np.ndarray
The resulting denoised image after max_iter iterations.
- scarlet.wavelet.get_multiresolution_support(image, starlets, sigma, K=3, epsilon=0.1, max_iter=20, image_type='ground')[source]¶
Calculate the multi-resolution support for a dictionary of starlet coefficients
This is different for ground and space based telescopes. For space-based telescopes the procedure in Starck and Murtagh 1998 iteratively calculates the multi-resolution support. For ground based images, where the PSF is much wider and there are no pixels with no signal at all scales, we use a modified method that estimates support at each scale independently.
- Parameters:
- image: 2D array
The image to transform into starlet coefficients.
- starlets: array with dimension (scales+1, Ny, Nx)
The starlet dictionary used to reconstruct image.
- sigma: float
The standard deviation of the image.
- K: float
The multiple of sigma to use to calculate significance. Coefficients w where |w| > K*sigma_j, where sigma_j is standard deviation at the jth scale, are considered significant.
- epsilon: float
The convergence criteria of the algorithm. Once |new_sigma_j - sigma_j|/new_sigma_j < epsilon the algorithm has completed.
- max_iter: int
Maximum number of iterations to fit sigma_j at each scale.
- image_type: str
The type of image that is being used. This should be “ground” for ground based images with wide PSFs or “space” for images from space-based telescopes with a narrow PSF.
- Returns:
- M: array of int
Mask with significant coefficients in starlets set to True.
- scarlet.wavelet.get_scales(image_shape, scales=None)[source]¶
Get the number of scales to use in the starlet transform.
- Parameters:
- image_shape: tuple
The 2D shape of the image that is being transformed
- scales: int
The number of scale to transform with starlets. The total dimension of the starlet will have scales+1 dimensions, since it will also hold the image at all scales higher than scales.
- scarlet.wavelet.multiband_starlet_reconstruction(starlets, generation=2, convolve2D=None)[source]¶
Reconstruct a multiband image
See starlet_reconstruction for a description of the remainder of the parameters.
- scarlet.wavelet.multiband_starlet_transform(image, scales=None, generation=2, convolve2D=None)[source]¶
Perform a starlet transform of a multiband image.
See starlet_transform for a description of the parameters.
- scarlet.wavelet.starlet_reconstruction(starlets, generation=2, convolve2D=None)[source]¶
Reconstruct an image from a dictionary of starlets
- Parameters:
- starlets: array with dimension (scales+1, Ny, Nx)
The starlet dictionary used to reconstruct the image.
- convolve2D: function
The filter function to use to convolve the image with starlets in 2D.
- Returns:
- image: 2D array
The image reconstructed from the input starlet.
- scarlet.wavelet.starlet_transform(image, scales=None, generation=2, convolve2D=None)[source]¶
Perform a scarlet transform, or 2nd gen starlet transform.
- Parameters:
- image: 2D array
The image to transform into starlet coefficients.
- scales: int
The number of scale to transform with starlets. The total dimension of the starlet will have scales+1 dimensions, since it will also hold the image at all scales higher than scales.
- generation: int
The generation of the transform. This must be 1 or 2.
- convolve2D: function
The filter function to use to convolve the image with starlets in 2D.
- Returns:
- starlet: array with dimension (scales+1, Ny, Nx)
The starlet dictionary for the input image.