Interpolation / nearest vs. linear or cubic - speed advantage

13 visualizaciones (últimos 30 días)
Brian
Brian el 13 de En. de 2016
Editada: Matt J el 13 de En. de 2016
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 comentario
dpb
dpb el 13 de En. de 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)?

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 13 de En. de 2016
Editada: Matt J el 13 de En. de 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.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by