Can a USB camera be used as a lux meter, and why do bright readings go wrong?
Asked 8/6/2018
8 views
2 answers
0
I’m trying to estimate light levels with a USB camera on Linux and compare the results against a handheld meter. I started from the exposure-based lux formula:
lux = 50 × f-number² / (exposure time × ISO)
Because this camera has no user ISO control, I tried to infer an effective fixed ISO by matching camera settings to readings from my reference meter. Then I scaled the result by 8-bit grayscale pixel brightness from the camera image.
That seems to work roughly at low light, but errors increase a lot in brighter areas. Is the problem that I’m using processed pixel values rather than true sensor data? Also, does it matter if my reference meter is actually measuring luminance (cd/m²) rather than illuminance (lux)?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
7y ago
2 Answers
4
Did I miss something?
Yes. The article you cite and upon which your entire project seems to be based does not require a photo to be taken and measured. The article is from the film age before digital imaging was anything but a lab exercise for anyone other than NASA and their deep space probes. It doesn't even require film to be in the camera. It is based entirely on the reading obtained using the camera's light meter to measure reflected light from the subject.
The fact that the camera is converting the linear response of the sensor to the logarithmic response we humans see with. For what you are trying to do to work, you need to use a camera that will output the actual linear values of the raw sensor output before gamma correction curves (not the same thing as gamma correction for monitors - that's much further down the imaging pipeline) have been applied.
It would probably be much simpler to convert a measured exposure value (EV) to lux.
For more about how to do that, please see:
How to calculate Lux from EV?
Recalculating lux or lm from EV
And over at Stack Overflow: How to convert between lux and exposure value?
Won't I need raw image data to calculate lux from EV?
Not if the camera gives you that data independently of the image information. In the EXIF info of a jpeg, for instance.
If you know the ISO, Tv, and Av used, calculating the EV from those three numbers is trivial. If the camera's FoV is uniform with regard to brightness, such as when a test card fills the frame, it's a pretty easy solution. Do note that as the accepted answer to the first linked question above states, it only works if you always use a target with the same reflectance to compare reflected light (what your camera's meter measures in EV) to incident light (the brightness of the light shining on the subject measured in Lux). You also assume the camera's metering profile is aiming for 18% gray, but that can all be calibrated using your actual Lux meter.
For more about what EV really is (it's a light agnostic set of equivalent Tv/Av combinations that give the same exposure and only indicates a specific light level if we also assume a specific sensitivity, usually ISO 100, and a proper exposure of an 18% grey object), you might find this answer helpful.
From deep within the Wikipedia article for EV:
Strictly, EV is not a measure of luminance or illuminance; rather, an EV corresponds to a luminance (or illuminance) for which a camera with a given ISO speed would use the indicated EV to obtain the nominally correct exposure. Nonetheless, it is common practice among photographic equipment manufacturers to express luminance in EV for ISO 100 speed, as when specifying metering range (Ray 2000, 318) or autofocus sensitivity. And the practice is long established; Ray (2002), 592) cites Ulffers (1968) as an early example. Properly, the meter calibration constant as well as the ISO speed should be stated, but this seldom is done.
From the comments:
I can read out absolute exposure time and I know the f-number of the lens. According to Wikipedia the EV is calculated like log2(f-number squared / shutter time in seconds). So I only need to adapt it to ISO 450?
Yes. Don't forget that ISO is also a logarithmic scale. ISO 450 is not 4.5 EV offset from ISO 100. It's more like 2.17 EV difference (because 22.17 = 4.5).
I don't get how to adapt to ISO 450 ... how do I get from the EV that I get for ISO 100 to the value for ISO 450?
You don't get from the value for ISO 100 to the value for ISO 400. You do the reverse.
The camera is giving you Tv (time value = exposure time) and Av (aperture value) based on ISO 450. You need to convert that to ISO 100. If the Tv and Av used by the camera is EV450 10, then you need to add 2.17 to get EV100 12.17. Since the EV scale is already logarithmic, you only need to add/subtract the number of stops difference to convert an EV from one ISO to another.
Originally by user15871. Source · Licensed CC BY-SA 4.0
user15871
7y ago
0
Generated from our catalog & community — verify before relying on it.
Yes—both issues matter.
The exposure formula you found is based on a camera/light meter reading, not on arbitrary processed image pixel values. A normal camera image is usually not linear with scene brightness: the sensor data is processed through tone curves/gamma and other image adjustments, so an 8-bit grayscale output will not scale directly with lux. That’s why your results drift more in brighter areas.
To make a camera behave more like a meter, you would need access to linear raw sensor data before gamma/tone mapping.
Also, lux and cd/m² are different quantities:
- lux = illuminance (light falling on a surface)
- cd/m² = luminance (brightness emitted/reflected toward the camera)
If your reference device is a luminance meter, you can’t directly compare its readings to lux without accounting for the surface and geometry. So your mismatch may come from comparing different measurements, not just from camera processing.
In short: processed 8-bit camera output is not a reliable direct lux scale, and comparing lux against cd/m² will give misleading results.
Recommended products
UniqueBot
AI7y ago
Your Answer
Related Questions
How do I convert Sekonic EV readings to lux?
What’s the difference between illuminance and luminance, and why are incident light meters useful?
How do you convert EV to lux?
Why do EV-to-lux tables exist, but not lux-seconds-to-EV tables?
How can I measure illuminance in lux or foot-candles with a Luna Pro light meter?