The subject is a bit challenging*. The short answer is:
- You look up the image profile, which contains the mapping to what it should look like in a known reference space.
However this look-up tells you what its intended to look like, not what it originally was. So if you want to measure the values you need to have an untainted source. Basically that means having control of all stages from capture to use. Remember your camera may be doing white balance, you need to account for that in addition.
A quick mental test to perform is:
- If the image does not look dark, then its not linear. Because ive never seen anybody but myself calibrate a monitor to linear.
The reverse however is not a truth test. So dark images are no more likely to be linear than light ones. There is an exception to the rule above, and that is synthetic images. They can be bright even if linear.
The real issue is that you can not really know whether or not the info you have is true. A image may have wrong metadata, or some processes may have mangled he image unknown to you. This is frequently the case for say bump maps, which can report srgb although intended as linear.
So to actually know the answer you need to know under what circumstances the image was made, by whom and what was done and intended with the image. or then just make naive assumptions.
- Maybe its just easier to say you can not do this very easily.
You simply need to purchase a calibration system for your hardware to control the pipeline. Or you can outsource this to a outside standards agency that does it periodically for you. In real manufacturing processes you also need to do quality control and quite frequent recalibration of systems.
The process is a bit tedious, so if you have more than 3 devices you need to dedicate one person for doing the calibration and workflow instructions.
But if all you need is somewhat better resuilts than before then byall means just buy a calibrator and run it periodically (or better yet constantly)
* So much that there is an entire industry for ensuring this quality control, So may be easier to hire a QC engineer.