spyrit.core.torch.walsh2_torch
- spyrit.core.torch.walsh2_torch(img, H=None)[source]
Returns a 2D Walsh-ordered Hadamard transform of an image.
- Args:
img (torch.tensor): Image to transform. Must have a shape of \((*, h, w)\) where \(h\) and \(w\) are the image height and width. The image must be square, i.e. \(h = w\). The image height and width must be a power of two.
H (torch.tensor, optional): 1D Walsh-ordered Hadamard transformation matrix. Specify this if you have already calculated the transformation matrix, or leave this field to None to use the Walsh-ordered fast Walsh-Hadamard transform. Defaults to None.
- Returns:
torch.tensor: Hadamard-transformed image. Has same shape as input image.
- ..warning::
This function is deprecated and has been moved to spyrit.core.torch. It is recommended to use
spyrit.core.torch.fwht_2d()instead for natural- or walsh-ordered Hadamard transforms.- Example:
>>> img = torch.rand(1, 3, 64, 64) # (batch, channels, height, width) >>> img_transformed = walsh2_torch(img) >>> img_transformed.shape torch.Size([1, 3, 64, 64])