1

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 Answers1

1

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 $$

mvw
  • 34,562
  • Slick answer, thanks! I got super smart though, and realized if I set the range to -1.71 to -0.55, it would behave correctly, and then I only would need to multiply the resulting value by -1. – brandonscript Nov 07 '15 at 17:55