Help Inversing this Log-to-Lin Function

christianlett

New member
Joined
Jun 28, 2014
Messages
3
Hello everyone,

I hope someone can help me find the inverse of the following function, which converts a log curve for a video signal into linear space. Actually there are two functions depending on the value of x:

if(x >= 0.08797653958944)
y = 0.21407624633431 * (pow(10.0, (((x - 0.0625) / 0.85630498533724 - 0.616596 - 0.03) / 0.432699)) - 0.037584) / 0.15151515151515 * 0.9
else // if x < 0.08797653958944
y = ((x - 0.0625) / 0.85630498533724 - 0.030001222851889303) / 3.53881278538813 * 0.9;

As you can see the numbers are all constant real numbers, so the only variable is x.

This works in my program to convert from SLog2 space to linear. What I need to do (but can't find anywhere online) is to convert back from linear to SLog2.

So far I've calculated the cutoff (i.e. the if(x >= z) statement for the inverse is:

if(x >= 0.00006341446058)

and the function for this part will require using log10() to reverse it.

Any help will be greatly appreciated. This is for an After Effects plugin I'm writing in C++.

Thanks in advance.

Christian
 
Hello everyone,

I hope someone can help me find the inverse of the following function, which converts a log curve for a video signal into linear space. Actually there are two functions depending on the value of x:

if(x >= 0.08797653958944)
y = 0.21407624633431 * (pow(10.0, (((x - 0.0625) / 0.85630498533724 - 0.616596 - 0.03) / 0.432699)) - 0.037584) / 0.15151515151515 * 0.9
else // if x < 0.08797653958944
y = ((x - 0.0625) / 0.85630498533724 - 0.030001222851889303) / 3.53881278538813 * 0.9;

As you can see the numbers are all constant real numbers, so the only variable is x.

This works in my program to convert from SLog2 space to linear. What I need to do (but can't find anywhere online) is to convert back from linear to SLog2.

So far I've calculated the cutoff (i.e. the if(x >= z) statement for the inverse is:

if(x >= 0.00006341446058)

and the function for this part will require using log10() to reverse it.

Any help will be greatly appreciated. This is for an After Effects plugin I'm writing in C++.

Thanks in advance.

Christian

Is your first equation:

\(\displaystyle y \ = \ \displaystyle{0.21407624633431 * 10^{\frac{f(x)- 0.037584}{0.15151515151515} * 0.9}}\)

where

f(x) = (x - 0.0625) / 0.85630498533724 - 0.616596 - 0.03
 
That tires me out; why not store most of those values, like:
a = 0.08797653958944
b = 0.21407624633431
c = 0.85630498533724
d = 0.616596
e = 0.432699
f = - 0.037584)
g = 0.15151515151515
h = 0.030001222851889303
i = 3.53881278538813

then go like this:
if(x >= a)
...and so on...

Hi Denis,

Yes you're quite right. Here are the two equations expressed algebraically:

y = a * (pow(10.0, (((x - b) / c - d - e) / f)) - g) / h * i

and

y = ((x - b) / c - j) / k * i;

a = 0.21407624633431
b = 0.0625
c = 0.85630498533724
d = 0.616596
e = 0.03
f = 0.432699
g = 0.037584
h = 0.15151515151515
i = 0.9
j = 0.030001222851889303
k = 3.53881278538813

Thanks for the replies.
 
Hi,

I've figured this out. It was actually quite simple.

The two functions inversed are:

y = a * (pow(10.0, (((x - b) / c - d - e) / f)) - g) / h * i becomes y = log10(((x / a) / i) * h * g) * f + e + d) * c + b

and
y = ((x - b) / c - j) / k * i becomes y = ((x / i) * k + j) * c + b

Thanks, Christian
 
Top