def get_frame(self, i, j):
"""
Perform interpolation to produce the deformed window for correlation.
This function takes the previously set displacement and interpolates the image for these coordinates.
If the cubic interpolation method is chosen, the cubic interpolation of this API is use.
For the bilinear method the build in scipy method `map_coordinates <https://goo.gl/wucmUO>`_ is used with *order* set to 1.
:param int i: first index in grid coordinates
:param int j: second index in grid coordinates
:returns: interpolated window for the grid coordinates i,j and the image set in initialization
"""
dws = self._shape[-1]
offset_x, offset_y = np.mgrid[-dws/2+0.5:dws/2+0.5, -dws/2+0.5:dws/2+0.5]
gx, gy = np.mgrid[0:dws, 0:dws]
grid_x = gx + self._distance*i
grid_y = gy + self._distance*j
ptsax = (grid_x + self._u_disp(i, j, offset_x, offset_y)).ravel()
ptsay = (grid_y + self._v_disp(i, j, offset_x, offset_y)).ravel()
p, q = self._shape[-2:]
if self._ipmethod == 'bilinear':
return map_coordinates(self._frame, [ptsax, ptsay], order=1).reshape(p, q)
if self._ipmethod == 'cubic':
return self._cube_ip.interpolate(ptsax, ptsay).reshape(p, q)
评论列表
文章目录