# Brightness and contrast VS Gamma, is it possible to identify the gamma “correction amount”?

Trichoplax question aroused my curiosity and the answers in this question also reminded me why I sometimes use different gamma "amounts" to enhance images.

Therefore, is it possible to determine the amount of gamma applied to an image by knowing its source (the original image)? I.e. can the mathematical formula be applied to compare two images and determine the difference in gamma "amount"?

Example: which of the following have a different gamma amount (I'll give you a non-edible cookie if you find out, and sorry trichoplax for snatching your ball):

• Do you mean you have both the pre and post gamma images and you want to find the gamma applied? – cifz Aug 6 '15 at 13:55
• @cifz Yes, the original image is from trichoplax's profile. – Armfoot Aug 6 '15 at 13:56
• I don't know for certain that the CC BY-SA 3.0 licence applies to profile images, but I operate under the assumption that anything that I use as an avatar is automatically licensed that way, and in any case I'm very happy for the image to be reused :) – trichoplax Aug 6 '15 at 18:26
• Meta Stack Exchange suggests that profile images are also CC BY-SA 3.0 so as long as you give credit you should be OK using anyone's avatar (provided they complied with the requirement to not post works they don't have the right to...). – trichoplax Aug 6 '15 at 18:42

If I get correctly what you are asking you basically just need to find the G in this equation:

$$Image_{out} = Image_{in}^G$$

This could be easily solved as

$$G = \frac{\log{Image_{out}}}{\log{Image_{in}}}$$

Because usually gamma is applied in a uniform fashion on the image, you can just pick any two non zero pixel values (one for source and one for destination) to find out the gamma value applied.

EDIT: As @ChristianRau pointed out, if you don't actually know if the image has been modified with gamma correction, you have to take an higher amount of samples and trying to fit a gamma function on those. If a fit to a gamma function results in too many significant outliers, then probably gamma correction wasn't the function applied.

• Though, I think part of his problem as posed in the question is also that he might not know if it is gamma corrected in any way at all or if the colors were not otherwise (linearly or whatever) modified in contrast to mere gamma correction. But ok, in this case you just take a bigger sample size and try to see if it can be approximated sufficiently well with a gamma transformation. – Christian Rau Aug 6 '15 at 14:07
• Exactly @ChristianRau, ideally it is to determine the difference even when other color transformations were applied. Thanks cifz, so if you sample several of each image's pixels and the resulting G is approximately 1, then we can conclude that no gamma correction was made? – Armfoot Aug 6 '15 at 14:27
• If also the other transformations are unknown, then to my limited knowledge I don't know how and if you can find the gamma. Intuitively I'd say you can't – cifz Aug 6 '15 at 14:35
• As @ChristianRau correctly said, you can try and fit the combination of transformations into a gamma function, but that will not tell you what gamma was applied on top of the other unknown transform, but rather an gamma that once applied to the source will give you roughly your destination – cifz Aug 6 '15 at 14:45