Mathematically exact inverse of mtf()?

johnpane

Well-known member
In the context of trying to use StarNet++ on linear images, I have seen some recommendations to temporarily stretch the image with mtf(m), and then after running StarNet++, to reverse the stretch with mtf(1-m). This does not seem to exactly invert the function.

Is there a mathematically exact way to invert mtf()?
 
Is there a mathematically exact way to invert mtf()?

Yes. The following property of the MTF:

x = mtf( mtf( x, m ), 1-m )

shows that the inverse MTF can always be implemented using 1-m as midtones balance parameter, as you guessed initially. This can be demonstrated from the definition of MTF:

MTF.svg


The second expression that you have posted is not the inverse MTF function.
The second expression that you have posted is equivalent to the inverse MTF:

MTF(x, 1-m) = mx/(1 - x + m (2x - 1)) = mx/(1 - m + x(2m - 1))

However, MTF(x, 1-m) can be invoked directly with PixelMath or JavaScript, so there is no need to use one of these equivalent equations.

Edit: If you are going to check this with PixelMath, take into account that the order of parameters is reversed in PixelMath's mtf function definition: mtf(m,x).
 
Last edited:
  • Like
Reactions: dld
Back
Top