If this were my algorithm, I would probably use linear interpolation (a common topic on here and other forums). However, Alf's direction might be closer to what you want, anyway. My advice at this point is to follow through on Alf's suggestions until that line of thought is exhausted. If his line of reasoning works, it will probably be easier to implement than trying to learn linear interpolation.