• Welcome to Dark Bit Factory & Gravity.
 

interpolating values

Started by Kirl, March 14, 2012

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Kirl

I need to interpolate 4 values, am I right that interpolation is basically calculating an average?

(value1 + value2 + value3 + value4) /4;

I never had any kind of formal math training so I'm mostly clueless when it comes to specific terms.
www.kirl.nl
Challenge Trophies Won:

hellfire

That's one possible method.
If your values have a spatial relationship you might want to consider gauss filter, median cut or linear regression, too.
Challenge Trophies Won:

Kirl

Thanks! Wikipedia is normally my fist stop for finding anything, but the mathematical notation is near impossible to decipher. Theory is often sufficient, but I find most of wikipedia's math articles are lacking in clarity as well.

I should probably just find some math training.  :whisper:
www.kirl.nl
Challenge Trophies Won:

hellfire

Quote from: Kirl on March 15, 2012Wikipedia is normally my fist stop for finding anything, but the mathematical notation is near impossible to decipher.
Maybe I can omit the math with a simple example.
Imagine a set of values "v" over the x axis:

int v[]= { 1, 3, 6, 5, 8,12,11,14 };
int x[]= { 0, 1, 2, 3, 4, 5, 6, 7 };


Let's take an averaging radius of 2 values, so for eg x=3 you'd weight the values 1..5.
The unweighted approach:

average= ( v[1] + v[2] + v[3] + v[4] + v[5] ) / 5;
       = ( 3 + 6 + 5 + 8 + 12 ) / 5 = 6.8


The gauss filter calculates a weighted average by taking the distance into account (the bigger the distance, the smaller the weight):

float maximum= 0.4;
float medium= 0.25;
float small= 0.05;
average= v[1]*small + v[2]*medium +  v[3]*maximum  + v[4]*medium + v[5]*small;
       = 6.25

Notice that the sum of all weights is 1.0.

For median cut you'd sort all values in the averaging range and pick the center.
Anomalies are expected to gather at the upper and lower end (so the center element is usually pretty average):

v[1..5]: 3, 6, 5, 8,12
sorted:  3, 5, 6, 8,12
center:  6

Challenge Trophies Won:

ttemper

@hellfire, great explanation on the different techniques. pixels will never look the same! :P K++

Kirl

Yes, an excellent explanation of the various forms, thanks a lot!

Proably best to replace the wikipedia articles with your post!  ;D
www.kirl.nl
Challenge Trophies Won: