Skip to main content
natrev
Legend
January 21, 2020
Answered

Question on the Gamma(mid-tone) value in levels adjustment layer

  • January 21, 2020
  • 3 replies
  • 3848 views

Hi EveryOne!,

I have few clarifications on the Gamma(mid-tone) adjustment of levels using photoshop

Please find the screenshot for more reference

The first screenshot shows the middle slider value is 1 and ColorSampler red value is 154

Once I change the ColorSampler red value is 84 and the middle slider value changed into 0.46

Is there is any formula available PS object model?

Or any suggestion to calculate?

Could anyone please help me to resolve the issue. 

-yajiv

 

 

 
 
 
This topic has been closed for replies.
Correct answer jazz-y

Before i accidentally added unnecessary elements to the solution of the original formula: Y = x ^ (1 / G). In numerical form it can be represented much easier: Y = ((154/255)^(1/0,46))*255 = 85.12

 

If we need to find G from the equation Y = x ^ (1 / G), then it will take the following form: G = LOG(X)/LOG(Y). In numerical form it can be represented as: G = LOG(154/255)/LOG(85/255) = 0.459 

 

Here is the link to google sheets: sample

 

1. Value from gamma
 
Input (X) 154
Gamma (G) 0,46
Output (Y) 85,19437485
   
2. Gamma from value
 
Input (X) 200
Value (Y) 220
Gamma (G) 1,645575473

3 replies

Legend
January 21, 2020
var input_low   = 0;
var gamma       = 0.46
var input_high  = 255;

var output_low  = 0;
var output_high = 255;

var input = 154;

output = Math.pow((input - input_low) / (input_high - input_low), 1/gamma) * (output_high - output_low) + output_low;

alert(output);
Kukurykus
Legend
January 21, 2020

I remembered your avatar from some past and checked you showed up again after nearly 2 years 😉

Legend
January 21, 2020

This is the gamma-compensation function: x ^ (1 / gamma). It uses to describe how human perceives a different values of brightness

* gamma is the coefficient you see in the panel

* all brightness values should be reduced to relative (0-255)/255

 

for example  = 154 - (154-((154/255)^(1/0,46)*255)) = 85,19

* I don’t know why there is a difference in rounding - most likely Adobe uses a rougher calculation to speed it up. To check, you can try on other values of the coefficients:

 

0,17: 154 - (154-((154/255)^(1/0,17)*255)) = 13,12

 

2.76: 154 - (154-((154/255)^(1/2,76)*255)) = 212,41

etc..

Kukurykus
Legend
January 21, 2020

May I know where have you found information about this?

Legend
January 21, 2020

I do not remember 🙂
Many years ago I read a book on the operation of CRT-displays and there was an example of signal conversion with this (or similar) function. It was used both for display on the screen and for encoding the brightness levels in the file.This was explained as close adaptation to the characteristics of human vision. Then I noticed that it is identical to the one used in the level, curves toos and exposure in camera raw - since then it’s in my head 🙂

 

May be there - The rehabilitation of gamma (but most likely not)