pylops.signalprocessing.Downsample2D

class pylops.signalprocessing.Downsample2D(dims, factors=2, sigma=None, truncate=4.0, axes=(-2, -1), method='fft', dtype='float64', name='D')[source]

2D downsampling operator.

Downsample a two (or more) dimensional array along a pair of axes by applying an anti-aliasing Gaussian filter followed by subsampling with a given decimation factor in each of the two directions.

Parameters:
dimslist or int

Number of samples for each dimension.

factorsint or tuple, optional

Decimation factors along each of the two axes. If a single value is provided, the same factor is used in both directions.

sigmafloat or tuple, optional

Standard deviations (in number of samples) of the Gaussian filter along each of the two axes. If a single value is provided, the same standard deviation is used in both directions. If None, the standard deviations are set to (factor - 1) / 2 for each direction.

truncatefloat, optional

Number of standard deviations at which the Gaussian filter is truncated. The filter has 2 * int(truncate * sigma + 0.5) + 1 samples along each direction.

axestuple, optional

Axes along which downsampling is applied.

methodstr, optional

Method used to calculate the Gaussian filtering (auto, direct or fft) - see scipy.signal.convolve for details.

dtypestr, optional

Type of elements in input array.

namestr, optional

Name of operator (to be used by pylops.utils.describe.describe)

Attributes:
hnumpy.ndarray

2d Gaussian filter applied prior to subsampling.

Coppylops.signalprocessing.Convolve2D

Gaussian filtering operator.

dimstuple

Shape of the array after the adjoint, but before flattening.

For example, x_reshaped = (Op.H * y.ravel()).reshape(Op.dims).

dimsdtuple

Shape of the array after the forward, but before flattening.

For example, y_reshaped = (Op * x.ravel()).reshape(Op.dimsd).

shapetuple

Operator shape.

explicitbool

Operator contains a matrix that can be solved explicitly (True) or not (False).

Raises:
ValueError

If dims has less than 2 dimensions, if axes, factors, or sigma do not contain 2 elements, if any element of factors is smaller than 1 or larger than half the size of the corresponding axis, or if any element of sigma is negative.

See also

pylops.signalprocessing.Convolve2D

2D convolution operator

pylops.Restriction

Restriction (or sampling) operator

Notes

The Downsample2D operator reduces the size of a two-dimensional array \(\mathbf{x}\) of size \(n_0 \times n_1\) by a factor \(f_0\) and \(f_1\) along the first and second direction, respectively. Direct subsampling of the input array would however lead to aliasing of any energy above the Nyquist wavenumber of the coarse grid; for this reason the array is first smoothed by a separable Gaussian kernel

\[h[p, q] = g_{\sigma_0}[p]\, g_{\sigma_1}[q], \qquad g_\sigma[p] = \frac{e^{-p^2 / (2\sigma^2)}} {\sum_{p'} e^{-p'^2 / (2\sigma^2)}}\]

with \(|p| \leq r_0\), \(|q| \leq r_1\), and \(r_i = \lfloor \tau \sigma_i + 0.5 \rfloor\) where \(\tau\) is the truncate parameter. In forward mode, filtering and subsampling are applied one after the other

\[y[i, j] = \sum_{p=-r_0}^{r_0} \sum_{q=-r_1}^{r_1} h[p, q] \, x[f_0 i - p, f_1 j - q] \quad \forall i=0,\ldots,\lceil n_0 / f_0 \rceil - 1, \; j=0,\ldots,\lceil n_1 / f_1 \rceil - 1\]

where the input array is assumed to be zero-padded outside of its boundaries. Since the adjoint of subsampling is zero-interleaving and the adjoint of convolution is correlation, in adjoint mode the data is first spread over the fine grid and then correlated with the same kernel

\[\begin{split}x[k, l] = \sum_{p=-r_0}^{r_0} \sum_{q=-r_1}^{r_1} h[p, q] \, \tilde{y}[k + p, l + q], \qquad \tilde{y}[k, l] = \begin{cases} y[k / f_0, l / f_1] & k \bmod f_0 = 0 \land l \bmod f_1 = 0\\ 0 & \text{otherwise} \end{cases}\end{split}\]

Note that, as the Gaussian kernel is real and symmetric, the operator is effectively the composition of a self-adjoint smoothing operator and a restriction operator.

Methods

__init__(dims[, factors, sigma, truncate, ...])

adjoint()

apply_columns(cols)

Apply subset of columns of operator

cond([uselobpcg])

Condition number of linear operator.

conj()

Complex conjugate operator

div(y[, niter, densesolver])

Solve the linear problem \(\mathbf{y}=\mathbf{A}\mathbf{x}\).

dot(x)

Matrix-matrix or matrix-vector multiplication.

eigs([neigs, symmetric, niter, uselobpcg])

Most significant eigenvalues of linear operator.

matmat(X[, pool])

Matrix-matrix multiplication.

matvec(x)

Matrix-vector multiplication.

reset_count()

Reset counters

rmatmat(X[, pool])

Matrix-matrix multiplication.

rmatvec(x)

Adjoint matrix-vector multiplication.

todense([backend])

Return dense matrix.

toimag([forw, adj])

Imag operator

toreal([forw, adj])

Real operator

tosparse()

Return sparse matrix.

trace([neval, method, backend])

Trace of linear operator.

transpose()

Examples using pylops.signalprocessing.Downsample2D

Downsampling

Downsampling