2

For a project I want to use a USB-camera (https://www.e-consystems.com/ar0330-lowlight-usb-cameraboard.asp) as a Lux-meter. I control the camera using v4l2 on Linux. I have a real lux-meter (https://gossen-photo.de/en/mavo-spot-2-usb) at hand so I can get "real" readings and confirm/crosscheck those made by my DYI Lux-meter.

I followed a guide about doing exactly this found at http://www.conservationphysics.org/lightmtr/luxmtr1.php which states as a formula:

Lux = 50x fnumber squared / (exposure time in seconds x ISO film speed)

There is no ISO setting so I guess the ISO is fixed. So I use the real lux-meter to get the lux of a certain spot and change the formula to

ISO = 50x fnumber squared / (Lux x exposure time in seconds)

to get the "fixed" ISO and I get a number of approximately 450.

From the camera I get an 8bit grayscale image. So I take the value of a pixel which I want to measure the lux and map it to a number between 0.0 and 1.0 and multiply that by the lux from the main formula:

Lux = pixel x 50 x fnumber squared / (exposure time in seconds x ISO film speed)

But the readings do not match the real lux-meters values. They seem to be correct for low-lux values but error increases exponentially with brighter spots that are measured.

Has anyone ever done something similar? Did I miss something?

Thanks for any advice.

EDIT update after answer below

Thanks to Michael's help and information found on https://en.wikipedia.org/wiki/Exposure_value#EV_as_a_measure_of_luminance_and_illuminance I'm at these formulas right now:

EV calculation, 2.17 being the compensation for ISO 450

float ev = log2(pow(fNumber, 2.0) / expTimeSeconds) + 2.17;

LUX calculation, pixelBrightness being a value between 0.0 (black) and 1.0 (white)

float lux = 2.5 * pow(2, ev) * pixelBrightness;

Weirdly, currently I get way to high Lux values, ranging aroung 1200 Lux for office indoors indirect lighting?

2nd EDIT update

So I was mistaking Lux and cd/m2 resp. illumination and lumination all the time - the Mavo-Spot 2 that I thought was a Lux-meter really is a "high precision luminance meter" that "measures the perceived brightness of back-lighted surfaces in candelas per square meter (cd/m²) or foot-lamberts (fL) in consideration of ambient light".

So I was trying to measure Lux with my camera but comparing the values to the ones I got from the Mavo Spot 2 which are cd/m2.

I am now using the formulas originally found in an old article (http://www.conservationphysics.org/lightmtr/luxmtr1.php):

float luminance = 12.4 * pow(fNumber, 2) / (expTimeSeconds * isoValue);
float lux = 50 * pow(fNumber, 2) / (expTimeSeconds * isoValue);

Of course the values are strongly simplified as they do not account for object material and reflectivity.

riccardolardi
  • 123
  • 1
  • 6

1 Answers1

4

Did I miss something?

  1. 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.

  2. 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.

Michael C
  • 175,039
  • 10
  • 209
  • 561
  • Thanks a lot for the information. Is there no way to "revert" or reverse-calculate the values back to pre-logarithmic conversion? – riccardolardi Aug 06 '18 at 08:52
  • Not really assuming it's also being reduced in bit-depth, which is normally the case. You'd need to know the algorithms used by the camera to convert the raw data to even come close to approximating it. But you are still going to lose the difference in bit-depth. Please see Approximating raw image data from app-less iPhone6 by reverse processing using meta data? – Michael C Aug 06 '18 at 09:06
  • Ok that makes sense, thanks a lot. Why does the article on http://www.conservationphysics.org/lightmtr/luxmtr1.php not mention this? Does it already assume a linear sensor response respectively raw image values? – riccardolardi Aug 06 '18 at 09:13
  • That article appears to have been written before consumers had digital cameras. It's based on the calculations of a film camera's analog light meter, not on the output of a digital imaging sensor. – Michael C Aug 06 '18 at 09:23
  • You might also find this answer helpful. – Michael C Aug 06 '18 at 10:25
  • correction: iso IS is linear and the EV is not, that's why there is nonlinear relation between the two – szulat Aug 06 '18 at 12:28
  • ISO is NOT linear. It is based on powers of two times 100, not multiples of two times 100. If ISO were linear and ISO 200 is one stop faster than ISO 100, then ISO 300 would be one stop faster than ISO 200, and ISO 500 would be four stops faster than ISO 100. – Michael C Aug 06 '18 at 13:20
  • Further, the relation between ISO and EV *IS* linear. One need only subtract or add the number of stops difference between EV expressed in two different ISOs. – Michael C Aug 06 '18 at 13:22
  • if you are confused about the meaning of "linear", it is when values increase by the same factor (multiplying), e.g. 1/100 sec ISO 100 is equivalent to 1/200 sec ISO 200 which is equivalent to 1/1000 sec ISO 1000 and so on. you might have heard about old film speed rating DIN, used before ISO was introduced - and it was using logarithmic scale: for example doubling the linear ISO value is equivalent to increasing logarithmic DIN value by 3, similarly how the logarithmic EV value increases by 1. – szulat Aug 06 '18 at 16:01
  • Just because the relationship of two logarithmic scales is linear (because they are both based on powers of 2) does not make each scale linear in its own right. That's absurd. ISO is not a linear scale. It is an exponential scale. A linear sequence is defined as a numerical sequence in which each term increases (or decreases) by the same amount, known as a common difference, from the previous term. By definition a sequence is linear only if adding the same number to each term in the sequence gives the value of the next term. – Michael C Aug 06 '18 at 16:50
  • Yes, the DIN scale is logarithmic. But scales based on (base 10)log 2 x 10, such as DIN and the decibel scale, are not the only logarithmic sequences! – Michael C Aug 06 '18 at 17:01