Wavelet2D.py 🚧¢

Source: LION/operators/Wavelet2D.py

Warning

This file has not yet received a complete narrative and docstring audit. Its public source-level API is listed automatically below.

2D orthogonal wavelet transform with periodised Daubechies wavelets.

class Wavelet2D(shape: tuple[int, int], wavelet_name: str = 'db4', level: int | None = None, mode: str = 'periodization', device: str | torch.device = 'cpu')

2D orthogonal wavelet transform with periodised Daubechies wavelets.

Parameters β€”β€”β€”- shape : tuple of int Image shape (H, W). wavelet_name : str PyWavelets wavelet name, for example β€˜db4’. level : int or None Decomposition level. If None, uses the maximum valid level. mode : str Signal extension mode. β€˜periodization’ gives an orthogonal transform. device : str or torch.device Device on which tensors are returned.

Wavelet2D.forward(self, x: torch.Tensor) torch.Tensor

Apply the wavelet analysis operator.

Note

Prefer calling the instance of the Wavelet2D operator as operator(x) over directly calling this method. See this PyTorch discussion.

Wavelet2D.adjoint(self, w: torch.Tensor) torch.Tensor

Adjoint of the wavelet analysis operator.

The adjoint is equivalent to the inverse wavelet transform. TODO: Add reference.

Parameters β€”β€”β€”- w : torch.Tensor Flat wavelet coefficient vector of shape (Nw,).

Returns β€”β€”- torch.Tensor Reconstructed image of shape (H, W).

Wavelet2D.inverse(self, w: torch.Tensor) torch.Tensor

Wavelet synthesis: flat coefficient vector -> image.

Parameters β€”β€”β€”- w : torch.Tensor Flat wavelet coefficient vector of shape (Nw,).

Returns β€”β€”- torch.Tensor Reconstructed image of shape (H, W).

Wavelet2D.domain_shape(self) tuple[int, ...]

Return the shape of the input domain.

Wavelet2D.range_shape(self) tuple[int, ...]

Return the shape of the output range.