I want to build a constant array(1..200) of single numbers to make a ‘lookup table’ to convert the position of the scrollbar which has values 1 – 200 to a value to use for applying gamma correction to an image.
The first array value would have a value somewhere anound 7.0 – 9.9 (photoshop uses 9.9). The middle one, array value 100, would need to be 1.0 exactly. Array value 200 would be about 0.01.
Can anyone tell me which algorithm to use?
I have been attempting to make the array using ‘trial and error’ in some test code based around the function Power(i, 2.2), but got nowhere.
I am using Delphi. I’m not asking the code though, just a steer in the right direction. Any help would be much appreciated.
2
Answers
Why not just take the difference and split it up by the number of steps.
Ex. 9.9-1 / 100 then you know the amount to increment.
I made a simple example in javascript to show what i mean:
Here is the fiddle:
https://jsfiddle.net/tuv5vfst/
This is not really a programming question, but one of math.
Assume a quadratic function, which is in the form of y=ax2+bx+c.
Fill in the three value-pairs known:
Three equations + three unknows = solvable by simple substitution.
In other words:
Gamma = 0.000402 * Pos^2 - 0.1305 * Pos + 10.0301