What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

levels, gamma, and midtone slider


ron_osborn

New Member
Messages
3
Likes
0
I've just joined and have started using VB for scripting photoshop CS2. I find its guide somewhat lacking and at times wrong. Is there better documentation anywhere without using the object browser?

At the momemt, I also have a need to use levels in my automation and am trying to figure out how photoshop computes gamma from its midtone slider in the levels dialog. I've assumed that gamma relates the output level (y) to the input level (x) in a power function, or y= x^(1/gamma). Assumming that you adjust the black (b) and white (w) points and scale to this new level range (w-b) then I get the following:

gamma = log((x-b)/(w-b)) / log(.5)

That seems to be pretty close to what photoshop does but thought I'd check whether I am missing something?
 
i like to look at pretty pictures.


oh ya and umm no idea. but if someone knows they will prob be found here. welcome to the board
 
Gamma is a power function:
output = input^(1/gamma)

That's why the slider is 0 to 1 on one side and 1 to 10 on the other.
Also, the input has to be normalized to the 0 to 1 range before inputting, then output scaled back up.

Oh... I see you have the gamma formula down.

What I recommend is scaling for b and w, then doing gamma.
You know, keep them as seperate operations instead of bunching them together.
This methodology has worked very well for me.

Wait . . . I think I'm thinking backwards to what you are asking.
Colour me confused.

And, from what poking around I've done, the object browser is the only decent way to go.
Everything else I've seen is sometimes unreliable and a messy jumble of poorly organized information.
 
Thanks for the confirmation. Now my next step is an attempt to programmatically analyze the histogram and set the gamma. Do you know of any tricks to do this. Many of my 1000s of images I'll be processing are significantly underexposed (but not all and I really don't want to presort things by inspection). I assume you can get a handle on exposure from the median level of the image. My underexposed images also have a sparse (even empty) highlight tail, so its pretty easy to set the white point clipping to .02 to bright things up. But my problem is guessing what the gamma level should be without visual inspection. It seems like the 90th percentile is good starting guess for underexposed images but if you have suggestions for setting gramma knowing the histo array I'd be greatful. Thanks again.
 
One way to auto gamma might be to 'half the histogram by count'.

If your image is 20x20, then the total count will be 400.
Start at the high end, move down, and add up the counts.
When you hit 400 / 2 = 200, that is your gamma point.

Make sense?

Or you might be able to use derivatives.
You know, calculus for peaks, delta change, and sigma stuff.
 
Ron, Welcome to PsG 8))

Here are some links that might help you get more info than in the scripting documentation: the official adobe forum, where you can maybe point out the problems of the documentation, if some engineers hang out there...

http://www.adobeforums.com/cgi-bin/webx?13@@.ef7f2cb

Another forum, well organized and specialized for Photoshop scripting can be found there: http://www.ps-scripts.com/

There is also a book: http://tinyurl.com/8mroj I don't know if it should be updated for CS2.

One adobe engineer has a site on the topic: http://www.tranberry.com/photoshop/photoshop_scripting/
 

Back
Top