Determine formula to calculate inverse range between two numbers

42 Views Asked by At

I've got a measurement for a graphics processing filter that increases intensity as the value decreases. For whatever reason, this filter's default value (minimum) is 1.75, and I've set the maximum value to 0.55.

Because all the other filters in this program increase intensity as the value increases, I don't want to have to write conditional statements just for this filter. Instead, I'd like to have it calculate the inverse values on the fly, so that the functional value increases from 0.55 to 1.75, while the filter value decreases from 1.75 to 0.55.

In short, I need to make an equation that can take:

  • 1.75 and translate it to 0.55
  • 0.55 and translate it to 1.75
  • with an average value of 1.15 (the value is equal here)
1

There are 1 best solutions below

1
On BEST ANSWER

Interpolation of the values: \begin{align} y &= (1-t) \, 1.75 + t \, 0.55 \\ &= 1.75 + t \, (0.55 - 1.75) \quad (t \in [0,1]) \\ &= 1.75 - 1.2 \, t \end{align} Interpolation of the parameters: $$ t = \frac{x - 0.55}{1.75-0.55} = \frac{x - 0.55}{1.2} $$ so $t(0.55) = 0$ and $t(1.75) = 1$.

This gives $$ y = 1.75 - 1.2 \frac{x - 0.55}{1.2} = 1.75 - (x - 0.55) = 2.3 - x $$