I'm looking for a general method for 2d interpolation of a coarsely sampled image. I'll use an example, taken from the scipy.interpolate (Python) page.

Say, I have this image, but instead of interpolating in the sense of going from e.g. a 512x512 grid to a 1024x1024 grid, I want to use the red/blue spots as data and re-define the unobserved green areas accordingly through an interpolation (so, the area between two red spots would be more yellow than green, and the area between two blue spots would be blue, not green). Of course, I'll do this programmatically. Language isn't too important, just looking for a method. I've tried kriging (available in IDL/Python), but I don't understand it enough to constrain the parameters, and for large (above ~64x64) arrays, it takes a lot of CPU/memory capacity.

Anyway, let me know if the question is too vague, and thanks...


Kriging with with an anisotropic variogram would seem to fit your case. Kriging calculates the values at the new to-be-interpolated locations as a weighted average. The kriging weights are based on the covariance structure of the observations (captured by the variogram model), where in general observations that are closer to the to-be-estimated location get a higher weight. When using an anisotropic variogram model, the covariance structure varies per direction, e.g. in a north-south direction an observation would get a higher/lower weight than an observation at a similar distance in the east-west direction.

Practically, I know that gstat supports anisotropic variogram models. You can use gstat as a stand alone program, although I greatly prefer the interface it has with R. See this tutorial of using gstat in R for more details, including an example of how to fit an anisotropic variogram model.


Unfortunately, scipy.interpolate.griddata interpolates only real values, not vectors like RGB.
(Your example from that page is in false color -- try some other plt.imshow( cmap=plt.cm.xx ).)
Invdisttree could do the job; it combines the fast scipy.spatial.cKDTree with inverse-distance weighting. See also SO questions/tagged/scipy+interpolation.

Apart from that, I believe (experts correct me) that kriging depends on a model of a random field underlying the data; do you have one ? Nearest-neighbor interpolation, on the other hand, "just works" .. or doesn't; cf. Breiman's Two Cultures.


This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .