| 202 | |
| 203 | |
| 204 | def get_weights(interp_method, projected_grid, field_of_view): |
| 205 | # the set of weights per each output pixels is the result of the chosen |
| 206 | # interpolation method applied to the distances between projected grid |
| 207 | # locations and the pixel-centers in the field of view (distances are |
| 208 | # directed, can be positive or negative) |
| 209 | weights = interp_method(projected_grid[:, None] - field_of_view) |
| 210 | |
| 211 | # we now carefully normalize the weights to sum to 1 per each output pixel |
| 212 | sum_weights = weights.sum(1, keepdims=True) |
| 213 | sum_weights[sum_weights == 0] = 1 |
| 214 | return weights / sum_weights |
| 215 | |
| 216 | |
| 217 | def apply_weights(input, field_of_view, weights, dim, n_dims, pad_sz, pad_mode, |