MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / nn_interpolate_1D

Function nn_interpolate_1D

numpy_ml/preprocessing/dsp.py:84–103  ·  view source on GitHub ↗

Estimates of the signal values at `X[t]` using a nearest neighbor interpolation strategy. Parameters ---------- X : :py:class:`ndarray ` of shape `(in_length, in_channels)` An input image sampled along an integer `in_length` t : list of length `k`

(X, t)

Source from the content-addressed store, hash-verified

82
83
84def nn_interpolate_1D(X, t):
85 """
86 Estimates of the signal values at `X[t]` using a nearest neighbor
87 interpolation strategy.
88
89 Parameters
90 ----------
91 X : :py:class:`ndarray <numpy.ndarray>` of shape `(in_length, in_channels)`
92 An input image sampled along an integer `in_length`
93 t : list of length `k`
94 A list of coordinates for the samples we wish to generate
95
96 Returns
97 -------
98 samples : :py:class:`ndarray <numpy.ndarray>` of shape `(k, in_channels)`
99 The samples for each (x,y) coordinate computed via nearest neighbor
100 interpolation
101 """
102 nt = np.clip(np.around(t), 0, X.shape[0] - 1).astype(int)
103 return X[nt, :]
104
105
106def bilinear_interpolate(X, x, y):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected