【发布时间】:2015-10-12 07:33:33
【问题描述】:
numpy/scipy 中是否有对二维 numpy 数组进行过采样的函数?
示例:
>>> x = [[1,2]
[3,4]]
>>>
>>> y = oversample(x, (2, 3))
会返回
y = [[1,1,2,2],
[1,1,2,2],
[1,1,2,2],
[3,3,4,4],
[3,3,4,4],
[3,3,4,4]]
目前我已经实现了自己的功能:
index_x = np.arange(newdim) / olddim
index_y = np.arange(newdim) / olddim
xx, yy = np.meshgrid(index_x, index_y)
return x[yy, xx, ...]
但它看起来不是最好的方法,因为它只适用于 2D 重塑并且有点慢......
有什么建议吗? 非常感谢
【问题讨论】: