【发布时间】:2018-08-14 21:48:49
【问题描述】:
我在不规则间隔的二维网格中有一些数据点,我想将其插入到规则网格中。例如,假设源数据来自鱼眼相机:
不规则源网格示例。注意...这些只是示例 - 一般来说,源数据也可能以不同的方式扭曲 - 但仍然来自网格。
# Source Data
x_src # A (n_src_rows, n_src_cols) array of x-coordinates of points
y_src # A (n_src_rows, n_src_cols) array of y-coordinates of points
# (x_src, y_src) form an irregular grid. i.e. if you were to plot the lines connecting neighbouring points, no lines would ever cross.
f_src # A (n_src_rows, n_src_cols) array of values.
# Interpolation Points:
x_dst # An (n_dest_cols) sorted array of x-coordinates of columns in a regular grid
y_dst # An (n_dest_rows) sorted array of y-coordinates of rows in a regular grid.
# Want to calculate:
f_dst # An (n_dest_rows, n_dest_cols) array of interpolated data on the regular grid defined by x_dst, y_dst
到目前为止,我一直在使用scipy.interpolate.griddata,并将源点展平为一维数组,但速度有点慢,因为它没有利用源数据点的网格结构(只有目标数据点)。它还会在不在相邻源网格点内的区域中进行插值(如果源网格的边界是凹的(如左图所示),则会发生这种情况。
SciPy/opencv 或类似库中是否有一个函数可以在源数据进入不规则间隔的网格时有效地进行插值?
【问题讨论】:
-
从优化的角度来看:如果不规范问题(或者它是病态的),就没有(好的)方法。你需要定义关于你可能的扭曲的假设。
-
有一个相当强的假设——源数据以网格形式出现。没有其他点会落在
(xy[i,j], xy[i+1,j], xy[i,j+1])之间的三角形中。 Scipy 的griddata没有使用这些知识(它对源数据的结构没有事先假设)。
标签: python opencv image-processing scipy interpolation