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

Function get_projected_grid

utils/resize_right/resize_right.py:126–138  ·  view source on GitHub ↗
(in_sz, out_sz, scale_factor, fw, by_convs, device=None)

Source from the content-addressed store, hash-verified

124
125
126def get_projected_grid(in_sz, out_sz, scale_factor, fw, by_convs, device=None):
127 # we start by having the ouput coordinates which are just integer locations
128 # in the special case when usin by_convs, we only need two cycles of grid
129 # points. the first and last.
130 grid_sz = out_sz if not by_convs else scale_factor.numerator
131 out_coordinates = fw_arange(grid_sz, fw, device)
132
133 # This is projecting the ouput pixel locations in 1d to the input tensor,
134 # as non-integer locations.
135 # the following fomrula is derived in the paper
136 # "From Discrete to Continuous Convolutions" by Shocher et al.
137 return (out_coordinates / float(scale_factor) +
138 (in_sz - 1) / 2 - (out_sz - 1) / (2 * float(scale_factor)))
139
140
141def get_field_of_view(projected_grid, cur_support_sz, fw, eps, device):

Callers 1

resizeFunction · 0.85

Calls 1

fw_arangeFunction · 0.85

Tested by

no test coverage detected