# How to compute luminous intensity in a photograph?

I have a photograph in raw format taken by a Nikon D-90 camera of a white LED spotlight shining on a wall in an otherwise dark room. I need to compute the relative luminous intensity of the bright center of the spotlight which is much brighter than the diffuse area around it. The reason is that I am trying to compute the maximum candelas of this spotlight from its lumens rating for that bright center area. I would like to know what percentage of the total light emitted (530 lumens) is going to the bright spot in the center since from that I can compute the candelas by dividing the fraction of the lumens that go to the center by the steradians of the center bright spot. I have Photoshop CS5 extended to examine the photograph. How can I get an approximation of the luminosity ratio of the brightness level in the center to the brightness of the whole area illuminated to compute this?

Will the RGB values of the photograph be a linear scale or some kind or logarithmic scale? If I can figure the relative brightness at a particular location, I could use the area that has that brightness level

• Haven't had the candela tag before, win! – dpollitt Jan 5 '12 at 1:33
• I realize that a photo, and photoshop, is involved in this question, but it's not actually a photography question as far as I can tell. – John Cavan Jan 5 '12 at 1:46
• @JohnCavan - More like an engineering and science type question? I kind of thought the same thing, but this is beyond my skill level so I wasn't really sure. – dpollitt Jan 5 '12 at 2:51

The raw RGB values are in a linear scale. Beware however that the RGB values of the rendered image are far from linear. I don't know whether Photoshop will let you access the raw RGBs, but you need them to do the computation.

To compute the intensity, you first have to integrate the whole spotlight, i.e. add all the pixel values. Divide this sum by the average pixel value at the bright center (averaged over an integer number of 2×2 blocks). You get something that I will call N which is equivalent to a number of pixels, i.e. you can say that the whole spot has as much light as a notional spot of uniform brightness (equal to the maximum brightness of the real spot) and extended across N pixels. From the geometry of your setup, you can convert this number into a surface area S = N × Sp on the wall, where Sp is the wall surface corresponding to one image pixel. From here you can get a solid angle Ω = S / d², where d is the distance between the LED and the wall. Ω is given in steradians.

Finally, your answer is I = Φ/Ω, where Φ is the luminous flux un lumens and I the luminous intensity in lumens per steradian (i.e. in candela).

All this assumes that the distance from the camera to the wall is significantly larger than the spot diameter. Otherwise you would have to throw some cosines in the integration.

• If you do this calculation on the raw data you also have to compensate for colors - it's unlikely the flash light gives the same amount of light in the red, green and blue pixels (but the factors should be easy to calculate by looking at nearby pixels) and filter hot and dark pixels - it's probably easier (and only a bit less accurate) to set the raw processor to linear (I believe adobe camera raw an do this), set the black and white points as close to the brightest and darkest pixels as possible and maybe convert to grayscale (of course assuming you don't have blown highlights) – Nir Jan 5 '12 at 9:06
• @Nir: You’re right: on the undemosaiced image, color can be an issue. The simplest solution would be to use as “the pixel values at the bright center” an average over an integer number of 2×2 blocks. I edited the answer to include this information. On a demosaiced image, and as long as the spot has uniform chromaticity, any linear combination of the R, G and B channels (including their sum or the use of a single channel) should give the correct result. – Edgar Bonet Jan 5 '12 at 10:15

You'll need to make sure no values are blown (i.e. value of 255), or else information will be lost. I believe you will have to convert the RGB values by applying a gamma correction to obtain absolute luminance values.

• If you have to work on the rendered pixel values, then you should reverse the tone curve applied by the renderer (the “raw developer”), which is more complicated than a simple gamma curve. – Edgar Bonet Jan 5 '12 at 8:44

I would be very leary of getting some app, like Photoshop, between me and the raw data because I don't know how exactly it dumbs things down. You are trying to make scientific measurements, so it would be best to deal with the raw data directly. You should write your own code to read the raw sensor values from the NEF file.

Yes, raw values are linearly proportional to the light level. I have actually tested this myself on a D3S. The rest is fairly straight forward math once you have the sensor values. Since you don't need much resolution, it might be simpler to deal with whole Bayer patterns as if they were one pixel. Keep in mind that while each color sensor has a linear response, the sensitivity of each color is not the same. You'll have to calibrate yourself what white is.

• Can you suggest a free tool for seeing the raw NEF file data? – WilliamKF Jan 9 '12 at 0:15
• @William: I don't really know since I use mostly my own software, but surely there are tools out there that read NEF files. The problem is what will be their output, and how much information will be lost in the process. Nikon NEF files are basically TIFF files, although Nikon adds some proprietary data too. I can read the raw sensor data in uncompressed NEF files, but not the special encrypted Nikon data yet. I also haven't found a clear description of the Huffman encoded "losslessly compressed" NEF format. – Olin Lathrop Jan 10 '12 at 23:39

You might try ImageJ — free image analysis software from NIH.

• How might one use this software to solve this particular problem? – mattdm Apr 30 '15 at 14:43