def apply_distortion_maps(self, arr, dispx, dispy):
"""
Applies distortion maps generated from ElasticDistortionState
"""
origarr = arr.copy()
xx, yy = n.mgrid[0:dispx.shape[0], 0:dispx.shape[1]]
xx = xx + dispx
yy = yy + dispy
coords = n.vstack([xx.flatten(), yy.flatten()])
arr = ndimage.map_coordinates(origarr, coords, order=1, mode='nearest')
return arr.reshape(origarr.shape)
评论列表
文章目录