Estimates of the pixel values at the coordinates (x, y) in `X` using a nearest neighbor interpolation strategy. Notes ----- Assumes the current entries in `X` reflect equally-spaced samples from a 2D integer grid. Parameters ---------- X : :py:class:`ndarray <n
(X, x, y)
| 51 | |
| 52 | |
| 53 | def nn_interpolate_2D(X, x, y): |
| 54 | """ |
| 55 | Estimates of the pixel values at the coordinates (x, y) in `X` using a |
| 56 | nearest neighbor interpolation strategy. |
| 57 | |
| 58 | Notes |
| 59 | ----- |
| 60 | Assumes the current entries in `X` reflect equally-spaced samples from a 2D |
| 61 | integer grid. |
| 62 | |
| 63 | Parameters |
| 64 | ---------- |
| 65 | X : :py:class:`ndarray <numpy.ndarray>` of shape `(in_rows, in_cols, in_channels)` |
| 66 | An input image sampled along a grid of `in_rows` by `in_cols`. |
| 67 | x : list of length `k` |
| 68 | A list of x-coordinates for the samples we wish to generate |
| 69 | y : list of length `k` |
| 70 | A list of y-coordinates for the samples we wish to generate |
| 71 | |
| 72 | Returns |
| 73 | ------- |
| 74 | samples : :py:class:`ndarray <numpy.ndarray>` of shape `(k, in_channels)` |
| 75 | The samples for each (x,y) coordinate computed via nearest neighbor |
| 76 | interpolation |
| 77 | """ |
| 78 | nx, ny = np.around(x), np.around(y) |
| 79 | nx = np.clip(nx, 0, X.shape[1] - 1).astype(int) |
| 80 | ny = np.clip(ny, 0, X.shape[0] - 1).astype(int) |
| 81 | return X[ny, nx, :] |
| 82 | |
| 83 | |
| 84 | def nn_interpolate_1D(X, t): |
nothing calls this directly
no outgoing calls
no test coverage detected