hilbert2#

class diffsptk.TwoDimensionalHilbertTransform(fft_length: list[int] | tuple[int, ...] | ndarray | int, dim: list[int] | tuple[int, ...] | ndarray = (-2, -1), device: device | None = None, dtype: dtype | None = None)[source]#

2-D Hilbert transform module.

Parameters:
fft_lengthint >= 1 or tuple[int, int]

The number of FFT bins.

dimtuple[int, int]

The dimension along which to take the Hilbert transform.

devicetorch.device or None

The device of this module.

dtypetorch.dtype or None

The data type of this module.

forward(x: Tensor) Tensor[source]#

Compute the analytic signal using the Hilbert transform.

Parameters:
xTensor [shape=(…, T1, T2, …)]

The input signal.

Returns:
outTensor [shape=(…, T1, T2, …)]

The analytic signal, where the real part is the input signal and the imaginary part is the Hilbert transform of the input signal.

Examples

>>> import diffsptk
>>> hilbert2 = diffsptk.TwoDimensionalHilbertTransform((1, 4))
>>> x = diffsptk.ramp(3).unsqueeze(0)
>>> z = hilbert2(x)
>>> z.real
tensor([[0., 1., 2., 3.]])
>>> z.imag
tensor([[ 1., -1., -1.,  1.]])
diffsptk.functional.hilbert2(x: Tensor, fft_length: list[int] | tuple[int, ...] | ndarray | int | None = None, dim: list[int] | tuple[int, ...] | ndarray = (-2, -1)) Tensor[source]#

Compute the analytic signal using the Hilbert transform.

Parameters:
xTensor [shape=(…, T1, T2, …)]

The input signal.

fft_lengthint, list[int], or None

The number of FFT bins. If None, set to (\(T1\), \(T2\)).

dimlist[int]

The dimensions along which to take the Hilbert transform.

Returns:
outTensor [shape=(…, T1, T2, …)]

The analytic signal.

See also

hilbert