Skip to content

Smooth bases (optix.basis)

Orthonormal DCT-II bases and the energy of their derivatives, used to describe smooth illumination. See Image formation and noise.

Smooth bases (orthonormal DCT-II) and their regularisers.

dct_basis

dct_basis(n, k=None, *, dtype=None, device=None)

Orthonormal DCT-II basis.

Φ[i, j] = cⱼ cos(π (i + ½) j / n) with c₀ = √(1/n) and cⱼ = √(2/n) for j ≥ 1. Built in float64, then cast.

Parameters:

Name Type Description Default
n int

Number of samples.

required
k int

Number of (lowest-frequency) basis functions, ≤ n. Default: n.

None
dtype optional

Output dtype and device (default: from the configuration).

None
device optional

Output dtype and device (default: from the configuration).

None

Returns:

Type Description
(n, k) Tensor

Basis functions in columns, Φᵀ Φ = I.

dct_bending

dct_bending(shape, k, *, order=2, spacing=1.0, dtype=None, device=None)

Diagonal regulariser of a separable DCT-II basis.

Energy of the order-th derivatives of each separable basis function ∏_d Φ_d[:, j_d]. The DCT-II functions diagonalise the discrete Laplacian with reflecting (Neumann) boundaries, with eigenvalues κⱼ = (2 − 2 cos(π j / n)) / h² (h = spacing). The energy of the order-m derivatives (sum over all ordered derivative multi-indices) is then (∑d κ)ᵐ: m = 1 is the membrane energy and m = 2 the bending energy.

The discrete eigenvalues are used (rather than the continuous (π j / (n h))²) so that, for order=1, the penalty equals the finite-difference energy exactly; both agree at low frequencies.

Parameters:

Name Type Description Default
shape sequence of int

Number of samples along each dim.

required
k sequence of int

Number of basis functions along each dim.

required
order int

Derivative order (1 = membrane, 2 = bending).

2
spacing float or sequence of float

Sample spacing along each dim.

1.0
dtype optional

Output dtype and device (default: from the configuration).

None
device optional

Output dtype and device (default: from the configuration).

None

Returns:

Type Description
(k1, ..., kd) Tensor

Penalty weight of each coefficient; zero for the DC term and increasing with frequency.

project

project(x, bases)

Separable analysis over the trailing dims.

Parameters:

Name Type Description Default
x (..., n1, ..., nd) Tensor

Signal.

required
bases sequence of (n_i, k_i) Tensor

One basis per trailing dim (e.g. from dct_basis).

required

Returns:

Type Description
(..., k1, ..., kd) Tensor

Coefficients x ×₁ Φ₁ᵀ … ×_d Φ_dᵀ.

reconstruct

reconstruct(coef, bases)

Separable synthesis over the trailing dims.

Parameters:

Name Type Description Default
coef (..., k1, ..., kd) Tensor

Coefficients.

required
bases sequence of (n_i, k_i) Tensor

One basis per trailing dim.

required

Returns:

Type Description
(..., n1, ..., nd) Tensor

Signal θ ×₁ Φ₁ … ×_d Φ_d.