Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The curves you have illustrated look a lot like <a href="http://en.wikipedia.org/wiki/Gamma_correction" rel="nofollow noreferrer">gamma correction</a> curves. The idea there is that the minimum and maximum of the range stays the same as the input, but the middle is bent like you have in your graphs (which I might note is <em>not</em> the circular arc which you would get from the cosine implementation).</p> <p>Graphically, it looks like this:</p> <p><a href="http://upload.wikimedia.org/wikipedia/commons/thumb/7/74/GammaFunctionGraph.svg/200px-GammaFunctionGraph.svg.png" rel="nofollow noreferrer">alt text http://upload.wikimedia.org/wikipedia/commons/thumb/7/74/GammaFunctionGraph.svg/200px-GammaFunctionGraph.svg.png</a></p> <p>So, with that as the inspiration, here's the math...</p> <p>If your x values ranged from 0 to 1, the function is rather simple:</p> <pre><code>y = f(x, gamma) = x ^ gamma </code></pre> <p>Add an xmax value for scaling (i.e. x = 0 to 100), and the function becomes:</p> <pre><code>y = f(x, gamma) = ((x / xmax) ^ gamma) * xmax </code></pre> <p>or alternatively:</p> <pre><code>y = f(x, gamma) = (x ^ gamma) / (xmax ^ (gamma - 1)) </code></pre> <p>You can take this a step further if you want to add a non-zero xmin. </p> <p>When gamma is 1, the line is always perfectly linear (y = x). If x is less than 1, your curve bends upward. If x is greater than 1, your curve bends downward. The reciprocal value of gamma will convert the value back to the original (x = f(y, 1/g) = f(f(x, g), 1/g).</p> <p>Just adjust the value of gamma according to your own taste and application needs. Since you're wanting to give the user multiple options for "sensitivity enhancement", you may want to give your users choices on a linear scale, say ranging from -4 (least sensitive) to 0 (no change) to 4 (most sensitive), and scale your internal gamma values with a power function. In other words, give the user choices of (-4, -3, -2, -1, 0, 1, 2, 3, 4), but translate that to gamma values of (5.06, 3.38, 2.25, 1.50, 1.00, 0.67, 0.44, 0.30, 0.20).</p> <p>Coding that in C# might look something like this:</p> <pre><code>public class SensitivityAdjuster { public SensitivityAdjuster() { } public SensitivityAdjuster(int level) { SetSensitivityLevel(level); } private double _Gamma = 1.0; public void SetSensitivityLevel(int level) { _Gamma = Math.Pow(1.5, level); } public double Adjust(double x) { return (Math.Pow((x / 100), _Gamma) * 100); } } </code></pre> <p>To use it, create a new SensitivityAdjuster, set the sensitivity level according to user preferences (either using the constructor or the method, and -4 to 4 would probably be reasonable level values) and call Adjust(x) to get the adjusted output value. If you wanted a wider or narrower range of reasonable levels, you would reduce or increase that 1.5 value in the SetSensitivityLevels method. And of course the 100 represents your maximum x value.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload