Interpolation / nearest vs. linear or cubic - speed advantage
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
dpb
am 13 Jan. 2016
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)?
Antworten (1)
Matt J
am 13 Jan. 2016
Bearbeitet: Matt J
am 13 Jan. 2016
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!