问题描述
我正在寻找一种方法来将更大数据中的数据插入一个较小的数组,反之亦然?
例如,我有一个包含137个数据元素的数组,我希望将这些数据调整为2000个数组元素。同时我想插入137个值,使它们均匀地适应新数组中的2000个元素。因此,
需要某种插值/采样机制,有点像以任意方式调整图像大小。
Hi,
I'm looking for a way to interpolate data in a larger array into a smaller array or vice versa?
If for example I have an array with 137 elements of data in it and I want to size that data up into an array with 2000 elements. At the same time I want to interpolate the 137 values so they fit evenly across the 2000 elements in the new array. I therefore need some sort of interpolation / sampling mechanism, a bit like resizing an image in an arbitrary fashion.
我不是在追求任何超级聪明的东西,所以真的只是简单的线性插值就可以了。我正在考虑调整图像的大小而没有任何平滑,因为它对我的应用程序来说不是必需的。
I'm not after anything that's super clever, so really just a simple linear interpolation will be fine. I'm thinking something along the lines of resizing an image without any smoothing as it's not necessary for my application.
有没有人有算法可以达到这个目的?
Does anyone have an algorithms that can achieve this?
非常感谢,
Damien
推荐答案
您可以通过创建4个值中的多项式来完成此操作。如果你使用2你得到一个线性函数,如果你使用4个点相邻,你会得到一个多项式3度。
you can do it by creating a polynom out of 4 values. If you use 2 you get a linear function, if you use 4 points next to each other you will get a polynom 3rd degree.
问候,克里斯
这篇关于将较小的阵列插入较大的阵列,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!