Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gamma correction formula : .^(gamma) or .^(1/gamma)?

Tags:

image

gamma

I'm looking for a simple gamma correction formula for grayscale images with values between 0 and 255.

Let's say that the gamma of my screen is 2.2 (it's an LCD screen so I would probably need to estimate it with a more complicated procedure, but let's assume my screen is behaving nicely).

Which one of the following formulas would be the correct one?

  1. Corrected = 255 * (Image/255).^2.2

OR

  1. Corrected = 255 * (Image/255).^(1/2.2)

(Those are destined to be MATLAB codes but I hope they are understandable even to non-MATLAB people)

I've been looking around on the Internet but found both formulas going around. I suspect (2) is the right one, and my confusion is due to the tendency to call "gamma value" the inverse of the actual gamma value, but I would really appreciate some feedback by people who know what they are talking about...

like image 285
user42174 Avatar asked May 13 '13 11:05

user42174


People also ask

What is gamma correction formula?

Technical Note: Gamma is defined by Vout = Vingamma , where Vout is the output luminance value and Vin is the input/actual luminance value. This formula causes the blue line above to curve. When gamma<1, the line arches upward, whereas the opposite occurs with gamma>1. 2.

What is gamma correction * 1 point?

Gamma correction or gamma is a nonlinear operation used to encode and decode luminance or tristimulus values in video or still image systems.

What is gamma correction factor?

1 Gamma correction. Gamma correction is simply a power law transform, except for low luminances where it's linear so as to avoid having an infinite derivative at luminance zero. This is the traditional nonlinearity applied for encoding SDR images. The exponent or “gamma”, as specified in the industry standard BT.

What gamma setting should I use?

Typically, if you are running on the Windows operating system, the most accurate color is achieved with a gamma value of 2.2 (for Mac OS, the ideal gamma value is 1.8). So when testing monitors, we strive for a gamma value of 2.2.


1 Answers

Both formulas are used, one to encode gamma, and one to decode gamma.

Gamma encoding is used to increase the quality of shadow values when an image is stored as integer intensity values, so to do gamma encoding you use the formula:

encoded = ((original / 255) ^ (1 / gamma)) * 255 

Gamma decoding is used to restore the original values, so the formula for that is:

original = ((encoded / 255) ^ gamma) * 255 

If the monitor does the gamma decoding, you would want to use the first formula to encode the image data.

like image 72
Guffa Avatar answered Nov 13 '22 22:11

Guffa