We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Photoshop Curves Math Equation
Page Index Toggle Pages: 1
Photoshop Curves Math Equation? (Read 892 times)
Photoshop Curves Math Equation?
Jun 15th, 2008, 5:50am
 
I was wondering if anyone knew the math behind the photoshop curves tool (http://www.cambridgeincolour.com/tutorials/photoshop-curves.htm)

basically, i'm just wondering how they calculate the output levels from the input levels - is it just:
http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Higher-order_curves

and if so, any ideas on how to implement the function?
Re: Photoshop Curves Math Equation?
Reply #1 - Jun 16th, 2008, 12:58pm
 
> basically, i'm just wondering how they calculate the output levels from the input levels

those graphs go from 0.0 to 1.0 on the x and 0.0 to 1.0 on the y. just go through the input image, use that as your x value  and output the y value that it maps to (with suitable input / output scaling)

the bezier curves are just a simple(ish) way of letting people define the mapping function.
Re: Photoshop Curves Math Equation?
Reply #2 - Jun 23rd, 2008, 2:04am
 
Summary: They're not beizer curves - if I knew what curves they were and how to mathematically express them, that would be amazing (but i don't... yet... T_T )

i'm pretty sure they're not beizer curves (done lots of research since I posted) - remember, beizer curves not only require control points on the line, but there are additional draggable control points that have different properties on the curve based on their distance away from the curve (such as in this picture:
http://en.wikipedia.org/wiki/Image:B%C3%A9zier_curve_in_Adobe_Illustrator_CS2.png )

also, give those four points, beizer curves don't actually go through all the 4 given control points, they only go through 2 as opposed to the curves in photoshop where the curve must go through all of your defined control points


I'm fairly certain (based on dissecting GIMP source code and various other bits of source) that the curves in question are an implementation of "catmull-rom splines"

now according to the processing documentation, this is actually what's called when you run curve() or curveVertex(), but i can't quite get it do work like the photoshop curves do (IE: defining control points using curveVertex() gives a different curve than the same control points in photoshop =/ )

if someone (who is better at java that i am, and that's not saying much because i'm terrible at java) could implement some of the filters at http://www.jhlabs.com/ip/ that would be really cool - i've been trying to tinker with the code there for days to no avail T_T
Page Index Toggle Pages: 1