# Calculate the right ISO and exposure compensation based on the ambient light

I'm new to photography and I'm working on this project where I need to find the right balance between ISO and exposure compensation, to take pictures in different environments. This is an App for android phones, so the options are limited. However I can use the light sensor of the phone to get the current ambient light, reported in lx.

I'm trying to automate the process of calculating the right ISO and exposure based on the received light but so far I'm unable to find material on this.

All the videos/tutorials/docs point to how to configure manually the ISO/Shutter Speed/Aperture for the perfect picture.

I believe some calculation method exists that has as an input the light level (lx) and as output the ISO and exposure compensation values ?

• Exposure compensation is not "equivalent to shutter speed". You seem to have a similar misconception of metering vs exposure compensation as in Is spot metering just an EV compensation? There is no way to automatically adjust exposure compensation because if auto exposure were doing it's job, there would be no need for exposure compensation. – xiota Oct 11 '19 at 10:19
• Exposure compensation isn't really about setting exposure based on the amount of light the camera is receiving per se (any light meter can do that without doing any EC), it is about calibrating the meter based on the overall reflectiveness of the contents of the scene and what in that scene the photographer wishes to be darker or lighter than a midtone. The light meter doesn't know if it is pointed at a black cat in a coal mine or a white cat in a snowstorm. It usually assumes both are medium gray and tries to expose so that they come out medium brightness in the resulting image. – Michael C Oct 15 '19 at 23:55

I don't know what 'exposure compensation value' means (is it EV?), but there is no automatic way of being able to do this. Simple-mindedly there are four parameters which define how bright (a bit of) the image will be:

• b, how bright the scene (or the bit of it corresponding to the bit of the image) is;
• s, how sensitive the sensor is, which is essentially its ISO (see below);
• t, the exposure time, in seconds;
• a, the aperture, given as f/11 or whatever, which we interpret as 1/11 or whatever.

The brightness of the image is then roughly proportional to

bsta2

It's clear from this that, if you know b, you can adjust s, t, and a to give an equivalently bright image. As an example, if

t = 1/100 second
s = 100
a = 1/8

then sta^2 = 1/64. But if

t = 1/50 second
s = 100
a = 1/11

then sta^2 = 2/121 which is very close to 1/64.

In other words an exposure of 1/50 at f/11 is the same as 1/100 at f/8.

Similarly I can adjust s:

t = 1/200 second
s = 200
a = 1/8

then the product sta^2 = 1/64 again: an exposure of 1/200s at ISO 200 at f/8 is the same as 1/100s at ISO 100 at f/8.

If you know b, then there are an infinite number of combinations of t, s, and a which will work: which you pick depends on factors other than how bright the scene is.

A note on s: I have written the above as if you could vary sensitivity, which really you can't: the sensor in the camera is as sensitive as it is. What you can do is then multiply the output of the sensor by some factor, which is, for these purposes, equivalent to controlling s. It's not really equivalent because of issues like noise and dynamic range, but it's good enough here.

(You can, of course, change the sensitivity of the sensor in a film camera, by changing film.)

I believe some calculation method exists that has as an input the light level (lx) and as output the ISO and exposure compensation values?

There are plenty of existing methods to set exposure parameters (ISO, exposure duration, and aperture) based on the amount of light received by a brightness sensor (usually called a light meter) in a camera.

Cameras with "Auto" exposure modes set all three parameters based on a hierarchy of prioritization used to produce a "best possible" image under the current shooting conditions.

• Lower ISO settings tend to result in a less "noisy" image
• Shorter exposure durations result in less blur due to camera or subject motion
• Narrower apertures allow deeper depth of field so that more of the scene is acceptable sharp and considered in focus

Unfortunately, to get all three of these things at what are usually considered optimal values, we need very bright light. We often need light that is much brighter than what we actually have with which to take a picture. Each of the three exposure parameters is weighed against the other two: how long can I expose before blur becomes noticeable? How wide can the aperture be opened before depth of field becomes too shallow? How much can I amplify the signal from the sensor before noise begins to noticeably degrade the image? Other factors, such as focal length (which affects the angular size of the field of view, and thus the amount of blur caused by a specific angular displacement of the camera during exposure) may also be considered.

For most phone cameras, aperture is fixed and not variable. That leaves duration (shutter time or shutter "speed", often abbreviated as Tv for 'time value') and ISO. In a digital environment 'ISO' really means "amplification" of the signal output by the imaging sensor, which only has one actual "sensitivity."

There are more than a few combinations of different Tv and ISO settings that will result in the same image brightness. If the light meter gives a brightness level suitable for a certain combination of aperture, Tv, and ISO, we can also expose for twice as long and amplify half as much, or we can expose for half as long and amplify twice as much and get the same image brightness. Each of those images will look different. If there is motion in the scene or the camera is moving during exposure, the longer Tv will show more movement. The shorter Tv will show less movement. But a shorter exposure at the same aperture means less light is actually being collected by the sensor, so we must amplify the signal from the sensor more by raising the ISO setting. This also amplifies the noise in the image.

But none of that above has to do with Exposure Compensation. It's strictly about Exposure, which assumes that the average brightness of the scene (or the average brightness of whatever portion of the scene is being metered) should be a medium value between pure black and pure white.

Exposure Compensation (EC) is a way of telling the camera to make the resulting photograph darker or lighter, on average over the total field of view (or whatever portion of the FoV that is being metered), than exactly halfway between pure black and pure white. We do not (usually) want a photo of a black cat in a coal mine to be the same brightness as a photo of a white cat in a snowstorm. We want one to be much darker than "medium bright". We want the other to be much brighter than "medium bright." The way this practically works out is that when we set an EC value, it calibrates the meter to center exposure a specific number of steps darker or brighter than the midtones halfway between totally dark and totally bright.

Many modern cameras can do a sort of internal EC when certain metering modes, such as 'Evaluative' (Canon) or 'Matrix' (Nikon) are selected. The light meter is divided into multiple segments and the brightness of each segment is measured independently. The resulting "map" of varying brightnesses is then compared to a library of different maps stored in the camera's memory. Each prestored map has a set of instructions on how to compensate exposure. The instructions for the stored map that is closest to the measured scene are used to adjust EC.

For example, a landscape scene with bright sky and darker land beneath it is very easily recognized by even the most rudimentary multi segment light meter. If the upper two thirds of the scene is very bright and the lower one-third is darker, the camera may be programmed to assume exposure should be set to capture details in the sky (such as very bright clouds) at the expense of allowing the lower one third of the scene to be grossly underexposed. If, on the other hand, the lower two-thirds of the frame are darker than the very bright upper one-third, the camera is probably programmed to expose for the darker areas at the expense of letting the sky be pure white and details in the bright sky will be lost.

In the past decade or so, dedicated light meters have advanced to the point that they now do multi segment metering in RGB+IR (red, green, blue, and near-infrared). They will even adjust EC based upon the specific colors in a scene compared to ever expanding libraries. Of course the most expensive camera models featured such RGB meters first, but now even many humble entry level cameras have RGB light meters. In the case of mirrorless cameras, metering is done directly off the RGB imaging sensor.

Many phones also use library based methods to compare with what the RGB image sensor in the camera is "seeing" and then take appropriate measures with regard to exposure. In darker light, the phone may even take multiple exposures and combine the results using auto alignment routines to increase the image quality of the final image.

• Your definition of EC is incorrect. The field of view is irrelevant except to the camera's metering system. EC is just telling the camera to over or under-expose once it has determined its exposure level from the metering system. In the case where spot metering is used to determine the camera's metered exposure level, only a very small area of the field of view is ever used in the exposure calculation. EC is just an adjustment on top of what the camera thinks is correct exposure according to its exposure mode. – John Hawthorne Oct 16 '19 at 13:17
• @JohnHawthorne Please read the answer again. I say nothing that contradicts what you are arguing. You can spot meter a black cat and a white cat and the camera will still try to make both of them gray. EC isn't really telling the camera to over-expose or under-expose. Instead, it's telling the camera how to calibrate the light meter for proper exposure when metering scenes (or spots) that are not supposed to be mid-tones in the final image. It's a way of telling the camera how many stops over or under 18% I want the metered object/scene to be. – Michael C Oct 17 '19 at 9:39
• Yes your edit now fixes the previously incorrect definition. – John Hawthorne Oct 17 '19 at 10:06
• @JohnHawthorne Not incorrect, just incomplete in not making clear what should be fairly obvious to anyone that a reference to the entire FoV would be with a metering mode that includes the entire FoV. – Michael C Oct 18 '19 at 7:20