### Author Topic: interpolating values  (Read 650 times)

0 Members and 1 Guest are viewing this topic.

#### Kirl

• Senior Member
• Pentium
• Posts: 986
• Karma: 219
##### interpolating values
« on: March 14, 2012 »

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

Code: [Select]
`(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

• Pentium
• Posts: 1226
• Karma: 443
##### Re: interpolating values
« Reply #1 on: March 14, 2012 »
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

• Senior Member
• Pentium
• Posts: 986
• Karma: 219
##### Re: interpolating values
« Reply #2 on: March 15, 2012 »
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.
www.kirl.nl
Challenge Trophies Won:

#### hellfire

• Pentium
• Posts: 1226
• Karma: 443
##### Re: interpolating values
« Reply #3 on: March 15, 2012 »
Wikipedia 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:
Code: [Select]
`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:
Code: [Select]
`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):
Code: [Select]
`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):
Code: [Select]
`v[1..5]: 3, 6, 5, 8,12sorted:  3, 5, 6, 8,12center:  6`
Challenge Trophies Won:

#### ttemper

• Atari ST
• Posts: 164
• Karma: 7
##### Re: interpolating values
« Reply #4 on: March 15, 2012 »
@hellfire, great explanation on the different techniques. pixels will never look the same! K++

#### Kirl

• Senior Member
• Pentium
• Posts: 986
• Karma: 219
##### Re: interpolating values
« Reply #5 on: March 15, 2012 »
Yes, an excellent explanation of the various forms, thanks a lot!

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