slope-limitation equation ?

F
Posted By
Fabrice
Dec 15, 2005
Views
484
Replies
12
Status
Closed
Hello,

Is the function for the "slope-limiting" feature of the Curves windows available somewhere ? From what I have found on Google, it seems that there is three part in the function : a power function, a linear function and a small spline between the two. But I don’t know where each starts…

Thank you in advance for your help !
Fabrice.

How to Master Sharpening in Photoshop

Give your photos a professional finish with sharpening in Photoshop. Learn to enhance details, create contrast, and prepare your images for print, web, and social media.

MR
Mike Russell
Dec 16, 2005
"Fabrice"wrote:
Is the function for the "slope-limiting" feature of the Curves windows available somewhere ? From what I have found on Google, it seems that there is three part in the function : a power function, a linear function and a small spline between the two. But I don’t know where each starts…

Hi Fabrice,

If I understand your question correctly, the curve window uses bicubic splines to generate its curve points from the specified control points. There are any number of references to the mathematical details, including Numerical Recipes in C.

I could not find the words "slope limiting" in Photoshop’s help file. Curvemeister has a feature that supports user controlled limits for the min and max slope of its curves. If I misunderstood your question, try again. —
Mike Russell
www.curvemeister.com
F
Fabrice
Dec 16, 2005
I could not find the words "slope limiting" in Photoshop’s help file. Curvemeister has a feature that supports user controlled limits for the min and max slope of its curves. If I misunderstood your question, try again.

Hello Mike,
I’m sorry, I mistranslated the name of the window … It is the "Levels" window, and not the "Curves" one. I’m talking about the "gamma" function, that is not a simple x^gamma, but something more complicated with a slope limitation for the dark tones. I’m looking for the equation of this function. This questions stirred a lot of controversy seven years ago (!) (see for example http://tinyurl.com/azb24 ), but I didn’t find the formula anywhere.

Sorry again for not being clear, and thank you anyway for answering. Fabrice.
MR
Mike Russell
Dec 16, 2005
"Fabrice" wrote in message
I could not find the words "slope limiting" in Photoshop’s help file. Curvemeister has a feature that supports user controlled limits for the min and max slope of its curves. If I misunderstood your question, try again.

Hello Mike,
I’m sorry, I mistranslated the name of the window … It is the "Levels" window, and not the "Curves" one. I’m talking about the "gamma" function, that is not a simple x^gamma, but something more complicated with a slope limitation for the dark tones. I’m looking for the equation of this function. This questions stirred a lot of controversy seven years ago (!) (see for example http://tinyurl.com/azb24 ), but I didn’t find the formula anywhere.

Ah – I remember that thread. I have no idea what they were talking about then or today.

Evidently, though, levels and curves are based on slightly different parametric curves, with the term "slope limiting" applied to the difference. You may find Stephen Marsh’s collection of utilities of interest. http://members.ozemail.com.au/~binaryfx/PSTV_windownloads.ht ml

Stephen includes a link to a levels2curve function that converts a Photoshop levels file to the corresponding curves file.


Mike Russell
www.curvemeister.com
GH
Gernot Hoffmann
Dec 16, 2005
Fabrice,

I remember the discussions as well.

Given y(x)=x^(1/G) , e.g. with G=2.2

Linear slope for small x, transition at x1:
y(x1)=x1^(1/G)

Slope:
s=y1/x1

Algo:
If x<x1 Then y(x)=s*x Else y(x)=x^(1/G)

x,y are normalized for [0,1].

I don’t know the transition value x1. Can be found
in T.Autiokari’s graphics (at that time different for
8 bit per channel and 16 bpc).

Best regards –Gernot Hoffmann
F
Fabrice
Dec 16, 2005
I don’t know the transition value x1. Can be found
in T.Autiokari’s graphics (at that time different for
8 bit per channel and 16 bpc).

Ok, thank you for the math, but it seems things are a little more complicated, according to this message from Chris Cox:
http://tinyurl.com/couya

"The gamma adjustment in Levels is a predefined power function with a linear slope, plus a small spline segment to smooth the meeting of the two functions."

In addition, I believed the transition value x1 would depend on the value of gamma. Do you know if it is the case or not ? If not, it is indeed easy to find its value from Timo’s example. I’m going to look at it.

Thanks,
Fabrice.
F
Fabrice
Dec 16, 2005
Evidently, though, levels and curves are based on slightly different parametric curves, with the term "slope limiting" applied to the difference. You may find Stephen Marsh’s collection of utilities of interest.
http://members.ozemail.com.au/~binaryfx/PSTV_windownloads.ht ml
Stephen includes a link to a levels2curve function that converts a Photoshop levels file to the corresponding curves file.

Thank you for the idea, but i’d prefer to find out the equation, as it would be required in a home-made program…

Fabrice.
GH
Gernot Hoffmann
Dec 16, 2005
Fabrice,

the answer is simple: Adobe doesn’t ever publish algorithms.

Replacing the vertical slope by a finite slope is probably not bad. I forgot the ‘small spline’ between the two segments.

All this is up to any image processing programmer, as long as PhS is not concerned.

E.g. you may have a look at improved Curves for special purposes here (p.9 … p.16) :
http://www.fho-emden.de/~hoffmann/hlscone03052001.pdf

No isolated linear part but continuous functions.

By the way: this HLS color space is good replacement for Lab, if accurate Lab is not required, but a decomposition of RGB into Hue, Saturation and Lightness (without discontinuities in the vicinity of the vertices).

Best regards –Gernot Hoffmann
F
Fabrice
Dec 17, 2005
E.g. you may have a look at improved Curves for special purposes
here (p.9 … p.16) :
http://www.fho-emden.de/~hoffmann/hlscone03052001.pdf

No isolated linear part but continuous functions.

Hi,
Thank you for the idea. With 0.028 instead of 0.05, the results are very close to photoshop’s ones. I have made several tests with Photoshop, and it seems that the transition value x1 depends on the value of gamma. I haven’t managed to "reverse engineer" Photoshop’s results yet. But your solution is quite elegant.

Fabrice.
GH
Gernot Hoffmann
Dec 17, 2005
Fabrice,

thanks for the feedback. You’re obviously familiar with
mathematics, therefore I’m ‘apologizing’ for telling you the simple mathematics (my first post).

By the way: could you solve your ICC-related problems,
as mentioned about one year ago in the Google forum
Color Engineering ?

Best regards –Gernot Hoffmann
R
Roberto
Dec 19, 2005
thanks for the feedback.

Hello,
some more feedback: I have spent a few more hours on trying to reverse engineer the equation, but to no success. I don’t see any pattern emerging when testing several gamma values.
For example the linear slope varies with gamma, and the value where the two curves begin to differ varies also a lot, but I did not find a satisfying relationship between those quantities:

G=1.5 ; slope=2.7 ; value=30
G=2.2 ; slope=4.5 ; value=28
G=3.0 ; slope=7.5 ; value=23
G=4.5 ; slope=22 ; value= 9
G=6.0 ; slope~60 ; value= 3

The problem is the "same" with your equation: the exponent is required to vary with G in order to mimic Photoshop’s behavior. The value 0.028 is satisfying for G around 2.2-3.0 .

By the way: could you solve your ICC-related problems,
as mentioned about one year ago in the Google forum
Color Engineering ?

Yes, I have found very similar ICC profiles by doing the maths from the theoretical curves given by Kodak, and by using Timo’s program. In fact, I’ve been quite impressed that his program should give so good results. I have tested other (commercial or not) programs, and their results were quite poor, compared to Timo’s ones…

Fabrice.
AM
Andrew Morton
Dec 20, 2005
wrote:
the answer is simple: Adobe doesn’t ever publish algorithms.

They do in patents. Although that doesn’t necessarily make them easy to find.

Andrew
R
Roberto
Dec 20, 2005
They do in patents. Although that doesn’t necessarily make them easy to find.

Yes, finding patents is not that difficult, look here:
http://tinyurl.com/bfbpv

However, I didn’t find anything related to gamma and slope-limitation. Did you have an idea concerning the relevant patent ?

Thanks anyway for the suggestion,
Fabrice.

MacBook Pro 16” Mockups 🔥

– in 4 materials (clay versions included)

– 12 scenes

– 48 MacBook Pro 16″ mockups

– 6000 x 4500 px

Related Discussion Topics

Nice and short text about related topics in discussion sections