Interpolation / nearest vs. linear or cubic - speed advantage

조회 수: 15 (최근 30일)
Brian
Brian 2016년 1월 13일
편집: Matt J 2016년 1월 13일
I want to speed up my code. Profiling indicates that a lot of time is spent in interp3 using linear interpolation.
I am benchmarking nearest interpolation right now. Is nearest worth using? Why don't I just calculate the index that is closest *myself*? Will it execute faster to build my own code to find the index or use nearest interpolation?
  댓글 수: 1
dpb
dpb 2016년 1월 13일
Only testing for your specific sizes of inputs and your implementation will answer that question...
If it makes no difference as to which result you obtain, why bother at all (rhetorical, yes, but to raise the point of what's the value of the end result)?

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2016년 1월 13일
편집: Matt J 2016년 1월 13일
Whether nearest-neighbor is worth using depends on whether you personally like the the quality of the result that it gives. People will use smoother interpolation methods like linear and cubic when they desire/require smoother results.
As for accelerating things, I wouldn't expect that your own implementation would be faster, if done in MCode. INTERP3 uses optimized compiled C code specifically with the idea of helping things go fast. You could browse the File Exchange for customized interpolation code offered by other contributors,
As another suggestion, if you are making repeated calls to interp3 on the same volume array, it will be more optimal to pre-construct on interpolation operator using griddedInterpolant(). This lets you skip argument parsing and setup steps that interp3 might be repeating unnecessarily.

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by