imagegamma

gamma correction formula : .^(gamma) or .^(1/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...


Solution

  • Gamma correction controls the overall brightness of an image. Images which are not corrected can look either bleached out or too dark. Suppose a computer monitor has 2.2 power function as an intensity to voltage response curve. This just means that if you send a message to the monitor that a certain pixel should have intensity equal to x, it will actually display a pixel which has intensity equal to x2.2 Because the range of voltages sent to the monitor is between 0 and 1, this means that the intensity value displayed will be less than what you wanted it to be. Such a monitor is said to have a gamma of 2.2.

    So in your case,

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