Does interp3 (with linear option) perform trilinear interpolation?

조회 수: 4 (최근 30일)
Jordan Y
Jordan Y 2018년 6월 15일
답변: Jordan Y 2018년 6월 17일
Can anyone confirm that interp3 (with the linear interpolation method) performs trilinear interpolation as described by: https://en.wikipedia.org/wiki/Trilinear_interpolation?
Similarly, can anyone confirm that interp2 (with the linear interpolation method) performs bilinear interpolation as described by: https://en.wikipedia.org/wiki/Bilinear_interpolation?

채택된 답변

John D'Errico
John D'Errico 2018년 6월 15일
편집: John D'Errico 2018년 6월 15일
Both interp2 and interp3 use n-dimensional tensor product linear interpolation, thus respectively bilinear and trilinear interpolation.
Interp2 uses bilinear interpolation.
Interp3 uses trilinear interpolation.
How do I know this? Both tools use griddedInterpolant, when called with the 'linear' option.
In the help for griddedInterpolant, we see the statement:
% The Method is one of the following:
% 'linear' - (default) linear, bilinear, trilinear,... interpolation
Just to be painfully sure, I checked. Both interp2 and interp3 produce a characteristic NONLINEAR interpolation, when applied along the diagonal of the corresponding 2-d and 3-d hypercubes. This is a known fact about bilinear and trilinear interpolation, that bilinear interpolation when applied through the main diagonal of a square produces a characteristic quadratic function along the path where X==Y. Likewise, a trilinear interpolant produces a characteristic cubic polynomial along the corresponding diagonal path where X==Y==Z.
Ok, I said this behavior is a known fact. I did not say it was a well known fact. Not difficult to prove though. Just for kicks, in case you might not believe me...
Vq = interp2(0:1,0:1,[0 1;1 0],0:.1:1,0:.1:1,'linear')
Vq =
0 0.18 0.32 0.42 0.48 0.5 0.48 0.42 0.32 0.18 0
plot(Vq)
You can do a similar test for interp3, generating a very pretty cubic curve.
Note that the nonlinear behavior of bilinear and trilinear interpolation along that diagonal are in fact a reason why other interpolation methods are sometimes chosen, when a linear interpolant is required. However, it is also true that any variety of "linear" interpolant will exhibit similarly interesting artifacts if you push them. And yes, there is at least one alternative method one can choose that also produces an interpolant that is arguably "linear".

추가 답변 (1개)

Jordan Y
Jordan Y 2018년 6월 17일
Thanks John D'Errico for such a detailed and fast answer!

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by