MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / get_weights

Function get_weights

utils/resize_right/resize_right.py:204–214  ·  view source on GitHub ↗
(interp_method, projected_grid, field_of_view)

Source from the content-addressed store, hash-verified

202
203
204def 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
217def apply_weights(input, field_of_view, weights, dim, n_dims, pad_sz, pad_mode,

Callers 1

resizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected