All Projects → ddemidov → mba

ddemidov / mba

Licence: MIT license
Scattered data interpolation with multilevel B-Splines

Programming Languages

C++
36643 projects - #6 most used programming language
go
31211 projects - #10 most used programming language

Scattered data interpolation with multilevel B-Splines

Build Status

This library provides the adaptive MBA algorithm from [1] implemented in C++11. This is a fast algorithm for scattered N-dimensional data interpolation and approximation. Python bindings are also provided.

Example of 2D interpolation in C++:

#include <mba.hpp>

int main() {
    // Coordinates of data points.
    std::vector<mba::point<2>> coo = {
        {0.0, 0.0},
        {0.0, 1.0},
        {1.0, 0.0},
        {1.0, 1.0},
        {0.4, 0.4},
        {0.6, 0.6}
    };

    // Data values.
    std::vector<double> val = {
        0.2, 0.0, 0.0, -0.2, -1.0, 1.0
    };

    // Bounding box containing the data points.
    mba::point<2> lo = {-0.1, -0.1};
    mba::point<2> hi = { 1.1,  1.1};

    // Initial grid size.
    mba::index<2> grid = {3, 3};

    // Algorithm setup.
    mba::MBA<2> interp(lo, hi, grid, coo, val);

    // Get interpolated value at arbitrary location.
    double w = interp(mba::point<2>{0.3, 0.7});
}

Same example in python:

from mba import *

interp = mba2(lo=[-0.1,-0.1], hi=[1.1,1.1], grid=[3,3],
              coo=[ [0.0, 0.0], [0.0, 1.0], [1.0, 0.0],
                    [1.0, 1.0], [0.4, 0.4], [0.6, 0.6] ],
              val=[0.2, 0.0, 0.0, -0.2, -1.0, 1.0]
              )

w = interp([[0.3, 0.7]])

Also see python/example.ipynb, python/layered.ipynb.

References

  1. S. Lee, G. Wolberg, and S. Y. Shin. Scattered data interpolation with multilevel B-Splines. IEEE Transactions on Visualization and Computer Graphics, 3:228–244, 1997, doi:10.1109/2945.620490.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].