我有一个图像的非均匀位置样本,并且想插入到规则网格中,因为(除其他外)大多数图像图形函数都需要一个规则网格。 我注意到有一些MatLab函数(例如见Image interpolation from random pixels)显然会这样做,但找不到一个R包。
下面是一个简单的例子。如何从非均匀2D位置插入到常规网格?
#make up some 2D func
y<-matrix(rep(1:10,10) -.5 + runif(100),nrow=10)
x<-matrix(rep(1:10,10) -.5 + runif(100),nrow=10)
inmat<-sin(x) + cos(y)
所以inmat
的值是随机位置。我想要某种outmat<-interpolate(inmat,x,y,gridx,gridy)
函数,其中inmat
,x
和y
是全部矩阵或全部向量(展开矩阵)。
我还看到SciPy有http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp2d.html这是做的。在R
包中有没有这样的功能,或者我需要从SciPy
还是MatLab
端口进行移植?
另请参见http://stackoverflow.com/questions/18769146/interpolating-an-irregular-grid – Andrie
可能重复[在地图上绘制插值数据](http://stackoverflow.com/questions/10047870/plotting-插值数据在地图上) – Spacedman
@Andrie谢谢 - 我正在查看'akima :: interp'函数并将回报。 –