{"id":19074693,"url":"https://github.com/linebender/rbf-interp","last_synced_at":"2025-04-29T16:27:21.992Z","repository":{"id":37686590,"uuid":"190624144","full_name":"linebender/rbf-interp","owner":"linebender","description":"An implementation of Radial Basis Function multidimensional interpolation","archived":false,"fork":false,"pushed_at":"2019-09-07T03:39:02.000Z","size":275,"stargazers_count":37,"open_issues_count":0,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T12:53:32.030Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linebender.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-06T17:42:17.000Z","updated_at":"2025-01-19T22:31:50.000Z","dependencies_parsed_at":"2022-09-15T10:00:37.274Z","dependency_job_id":null,"html_url":"https://github.com/linebender/rbf-interp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Frbf-interp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Frbf-interp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Frbf-interp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Frbf-interp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linebender","download_url":"https://codeload.github.com/linebender/rbf-interp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251538884,"owners_count":21605599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T01:52:02.298Z","updated_at":"2025-04-29T16:27:21.974Z","avatar_url":"https://github.com/linebender.png","language":"Rust","funding_links":[],"categories":["Code"],"sub_categories":["RBF Network"],"readme":"# rbf-interp\n\nThis crate contains an implementation of Radial Basis Function multidimensional interpolation.\nFor an excellent introduction to the topic, see the [SIGGRAPH 2014 course notes].\n\nThe input is a set of datapoints, each of which has coordinates in some multidimensional\nspace, and a value, also provided as a vector. For example, for the colorfield images below,\nthe coordinates are 2D, and the values are a 3-vector, one each for red, green, and blue.\nThe result is a `Scatter` struct that can then be evaluated at any coordinate. The idea\nis that the values vary smoothly with the coordinates, but coincide with the input at each\nof the provided datapoints.\n\nThere are a number of approaches to multidimensional interpolation, but the focus of this\ncrate is the family of radial basis functions. These include [Polyharmonic splines], of which\nthe thin plate spline is an instance, a Gaussian radial basis function, and others\n(muti-quadric and inverse multi-quadric). The Gaussian and multi-quadric variants also have\na tunable size parameter.\n\nIn addition, there is an \"order\" parameter that controls low-order polynomial terms. An\norder of 0 means no additional terms, just pure basis functions. An order of 1 means a constant\nterm, and and order of 2 means an affine term. With these additional terms, there is a\n\"best-fit\" constant or affine approximation of the input, and the basis functions are layered.\n(For a more precise description, see section 3.1 of the SIGGRAPH notes). Note that quadratic\nand higher order polynomials also make sense, but are not implemented currently.\n\nThe plots below are made with a Gaussian basis function with a deliberately too-small size\nparameter (0.05), to show more clearly the effect of the polynomial term:\n\n![Gaussian order 0](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/gaussian_pure.svg?sanitize=true)\n![Gaussian order 1](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/gaussian_constant.svg?sanitize=true)\n![Gaussian order 2](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/gaussian_affine.svg?sanitize=true)\n\nWith a reasonable value (1.0), results are spot-on:\n\n![Gaussian with properly tuned width](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/gaussian1.svg?sanitize=true)\n\nHere are comparisons with two of the other basis functions, thin plate and triharmonic:\n\n![Thin plate](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/thinplate.svg?sanitize=true)\n![Triharmonic](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/triharmonic.svg?sanitize=true)\n\nNote that the interpolation is pretty good, but the extrapolation (the region from 1.8 to 2.0\nin these plots) is weaker.\n\n## Colorfield results\n\nA major motivation for this crate is computing smoother interpolation for [variable fonts].\nEarlier work in this space is [MutatorMath], which uses multilinear interpolation for the\ntask. The project page has a \"colorfield\" to demonstrate their interpolation techniques, which\nplaces an (r, g, b) color at each point in a 2D coordinate space. Note that for fonts generally\nthe output is a 2D coordinate and the input is any number of variation axes (perhaps weight\nand width are the most common), but the colorfield is a good way to visualize the behavior of\nan interpolation scheme.\n\nBelow are the image from MutatorMath (scaled down), and radial basis results using Gaussian\nbumps with radius 4.5 and thin plate splines\n\n![MutatorMath](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/mutatorMath_colorField_small.png)\n![Gaussian radius 4.5](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/m_gaussian4_5.png)\n![Thin plate spline](https://raw.githubusercontent.com/linebender/rbf-interp/master/docs/m_thinplate.png)\n\nThe radius tuning parameter has a fairly profound effect on the results. This is a liability\nin many application domains for multidimensional interpolation, but perhaps a good thing\nfor variable fonts, as it provides choice over the tradeoff between smoothness (perhaps\nwith overshoots) and local control. Curious people are encouraged to experiment with the\n`mutator` example in the examples directory.\n\nTo run the example from a Unix shell:\n\n```\ncargo run --example mutator \u003e image.ppm\n```\n\n## Other resources\n\nThe following articles were of interest:\n\n* [Data Interpolation with Radial Basis Functions (RBFs)\n](http://shihchinw.github.io/2018/10/data-interpolation-with-radial-basis-functions-rbfs.html)\n\n* [A Practical Guide to Radial Basis Functions](https://num.math.uni-goettingen.de/schaback/teaching/sc.pdf)\n\n* [Radial Basis Function Interpolation](https://core.ac.uk/download/pdf/37320748.pdf) (Wilma du Toit Masters Thesis)\n\n* [A simple Julia implementation](https://gist.github.com/lstagner/04a05b120e0be7de9915)\n\n* [Thin plate splines in darktable](https://www.darktable.org/2016/05/colour-manipulation-with-the-colour-checker-lut-module/)\n\nThanks to Jacob Rus for discussion and resources, and to [LGM 2019]\nfor providing a stimulating environment to develop these ideas.\n\n[SIGGRAPH 2014 course notes]: http://scribblethink.org/Courses/ScatteredInterpolation/scatteredinterpcoursenotes.pdf\n[MutatorMath]: https://github.com/LettError/MutatorMath\n[Polyharmonic splines]: https://en.wikipedia.org/wiki/Polyharmonic_spline\n[variable fonts]: https://docs.microsoft.com/en-us/typography/opentype/spec/otvaroverview\n[LGM 2019]: https://libregraphicsmeeting.org/2019/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinebender%2Frbf-interp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinebender%2Frbf-interp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinebender%2Frbf-interp/lists"}