我正在尝试根据适合位移场的scipy.interpolate.Rbf转换3D图像。所以我必须独立地插补每个坐标
# scipy.interpolate.Rbf fitting
# coordinate_mapping contains the x y z positions of tracked positions
interp_mapping = tuple(Rbf(*coordinate_mapping[:, :, 0].T, coordinate_mapping[:, x, 1], function="thin_plate") for x in range(3))
class interpolated_field:
"""Helper class just to have a callable vector field to put into transformation functions"""
def __init__(self, field_tuple):
self.field_tuple=field_tuple
def __call__(self, coords):
return tuple(self.field_tuple[x](*coords) for x in range(3))
interp_field = interpolated_field(interp_mapping)
然后我用
变换图像# transposed_frame is of shape (632, 352, 35)
inverse_transformed = geometric_transform(transposed_frame, interp_field, prefilter=False)
但是在一个帧上执行转换大约需要13分钟,我想做几百个。此功能是否有更快的版本?或以某种方式对其进行多线程处理或将其发送到GPU?