I am struggling understanding gamma encoding/decoding.
So the colors I see and the values I get from a color picker application(like MS Paint) are already in sRGB space(correct?).
Assume the color picker gives color C1=(186,70,2). If I create an image programmatically with all pixels in color C1 and Do Not apply gamma encoding C1^(1/gamma), and save it as ppm file, I see exactly same color C1 on opening the file on a viewer.
But this is not the case in my experiment. I save values of color C1 into the file and see color C1. And this is what I don't understand: if the display raise the input color C1 by gamma why do I still see C1 on the screen? Should I not expect to get C1^gamma?
Basically here is the ppm file with all pixel RGB values (128,128,128). No gamma-encoding has been applied. That is simply writing linear values of 128.
P3 400 400 255 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 ...
According to Wikipedia Gamma correction page:
For example, when using 24-bit RGB color (8 bits per channel), writing a value of 128 (rounded midpoint of the 0–255 byte range) in video memory it outputs the proportional ≈ 0.5 voltage to the display, which it is shown darker due to the monitor behavior.
Wikipedia clearly says write a value 128 and you will see a darker than you expect. Those values in my ppm file are not gamma-encoded and so I expect seeing a darker color(0.5^gamma) on the screen. Yet this is not the case and if you open this file on a viewer you will see pixels with brightness half as white. That is what I don't get.
Update 2 (After Nathan good answer..)
So with input of 186 the screen outputs 50% of white intensity? And the eye perceives it as 50% as bright as white? is this right? But if the screen output is 50% in intensity, and eye has its own curve(roughly power of 1/gamma) then the screen output of 50% should be seen brighter?
Another question I have is that, So is it the programmer responsibility to write gamma-corrected values into the file or the whatever API we use to save image file formats does it internally? For example i use .Net Bitmap class. Do I need to save bitmap with gamma-encoded values or Bitmap.Save method does it? I ask this since according Wikipedia, and you mentioned this too, almost all image formats are encoded
binary data in still image files (such as JPEG) are explicitly encoded (that is, they carry gamma-encoded values, not linear intensities)