Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: rain_storm on July 05, 2011

Title: Frame interpolation?
Post by: rain_storm on July 05, 2011
How would you go about interpolating inbetween frames from a before and after? Best I can think of would be to choose a pixel, take the colour before add the colour after and average the two to create an inbetween. Is there a better solution?
Title: Re: Frame interpolation?
Post by: benny! on July 05, 2011
You could also take the surrounding pixel colours into account (giving them a lesser weight) - but generally I am agreeing with you!
Title: Re: Frame interpolation?
Post by: Jim on July 05, 2011
You can get lots of inbetween frames too.
Say you have a number between 0 and 1, where 0 means entirely the previous frame, and 1 means entirely the next frame, and anything in between is a blend of some sort, then you can get
Code: [Select]
'pseudo code
r0,g0,b0 = pixel from previous frame
r1,g1,b1 = pixel from next frame
f = blend_factor_between_0_and_1
r = r0 + f * (r1 - r0)
g = g0 + f * (g1 - g0)
b = b0 + f * (b1 - b0)

But, exactly as you say, a 50:50 blend can be done like
Code: [Select]
r = (r0+r1)/2
g = (g0+g1)/2
b = (b0+b1)/2
which is a smidge simpler to compute

Jim
Title: Re: Frame interpolation?
Post by: hellfire on July 05, 2011
If you want a more convincing approach (and have plenty of cpu cycles to share) you could take the direction of motion into account.
For a start you could try to calculate blockwise motion vectors using autocorrelation (see eg block motion compensation (http://en.wikipedia.org/wiki/Motion_compensation#Block_motion_compensation)).
Title: Re: Frame interpolation?
Post by: rain_storm on July 05, 2011
Thanks guys. That bock motion compensation looks like it's worth trying out. I hear that lag is a problem with interpolation so you cannot boost a low framerate from 12 fps to 24, but when you're talking about demos lag is hardly an issue. At speeds of 30 fps the lag would be barely noticable.
Title: Re: Frame interpolation?
Post by: rain_storm on July 07, 2011
merely interpolating the colours by taking the average works well, but only if the framerate is already high enough (say 25fps being boosted to 50fps). When the camera stops moving the effect disappears but when the scene is in motion it helps greatly to keep things greasy fast.
Title: Re: Frame interpolation?
Post by: benny! on July 07, 2011
Looking good!