def get_interpolated_pixel_color_rbspline(pts, s_im, size):
"""given pts in floats, linear interpolate pixel values nearby to get a good colour"""
pts = clamp(pts, size)
s_im = np.atleast_3d(s_im)
ys,xs = size
ycoords, xcoords = np.arange(ys), np.arange(xs)
out = np.empty(pts.shape[1:] + (s_im.shape[-1],),dtype=s_im.dtype)
pts_vec = pts.reshape((2,-1))
out_vec = out.reshape((-1,s_im.shape[-1])) #flatten for easier vectorization
for i in range(s_im.shape[-1]): #loop over color channels
rbspline = RectBivariateSpline(ycoords, xcoords, s_im[...,i])
out_vec[:,i] = rbspline.ev(pts_vec[0],pts_vec[1])
return out
### Functions generating SL(2,C) matrices ###
# Do not need to be vectorized #
sphere_transforms_numpy.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录