0
votes

I have a task of interpolating a 2d array of NxM to AxB, where A > N and B > M. The point of it is building a simple color coded image of an array (heat map).

Do I understand correctly that, for example, an array of 3x3 (all known values)

A B C
D E F
G H I

Should be interpolated in, say, 6x6 in this manner

A x B x x C
x x x x x x
D x E x x F
x x x x x x
x x x x x x
G x H x x I

where x marks unknown yet interpolated value, right?

Can this be done in two nested for loops? I found bilinear interpolation formula, but having some trouble with adapting it to (i, j) of resulted array loop. Any advices? Thanks in advance.

1
"Should be interpolated in, say, 6x6 in this manner..." That's a judgment call. As I'm sure you've discovered there are many resampling methods - en.wikipedia.org/wiki/Resampling_%28bitmap%29 - and the one you choose depends on a lot of factors. - Jordan Running
Even considering my heat map task? Result I need is similar to this upload.wikimedia.org/wikipedia/commons/c/c6/Bilininterp.png - spacevillain

1 Answers

1
votes

You could use a library like .NET, Qt or SDL to do it, it's a common application task.

If you want to implement it yourself, read about Bilinear filtering rather than bilinear interpolation. "Interpolation" generally means you interpolate just between two values - once you have an image, it's called filtering.

Consider nicer looking filters such as bicubic, too.