# How to calculate difference in exposure between to given frames

I have a question regarding exposure.

I have a project I am working on where I need to be able to calculate the exact number of stops between two given exposures, with the end goal being to match the exposure of the two frames. Using metadata to match exposures isn't possible as much of the difference will be due to ambient light changing.

I initially tried calculating average luminosity across each of the two frames, but due to the fact that exposure is a effectively multiplier on each individual pixel (and thus summing the pixels and multiplying from that value is not equivalent), this technique led to very significant error.

I can adjust one of the images using trial and error visually to approximate the value (just fiddling a slider in RawTherapee), but that's neither accurate enough, nor fast enough (hundreds of frames will be processed). If an intelligent (i.e. not brute forced) method of achieving the same goal does exist, I will be able to run it automatically through a small script.

Does anyone know an accurate mathematical way to calculate the difference in exposure in stops between two frames?

I understand it's a very specific question, so thanks in advance to anyone who has any advice. Anything at all is a great help

• This sounds like an X-Y problem. Given that the camera attempts to make a shot taken in bright sunlight have the same approximate tonal range as one taken on a cloudy day under the forest canopy, the end result images are far more similar than the original views. Exposure is the amount of adjustment your camera makes in shutter speed, signal amplification (ISO) and aperture to achieve that end. As such, if you really want to know the difference in exposure, the metadata is probably where you want to start, as analyzing the images themselves will be misleading at best. – twalberg Jan 9 at 21:11
• The images are all shot in raw using manual settings, so the files are generally consistent to the scene. The important changes are those to ambient light, which aren't expressed in a file's metadata. – James Voss Jan 9 at 21:18
• To clarify: you're attempting to use the image to figure out how bright the scene was, so as to compare the scene brightness between images? I'm genuinely curious, why does it even matter? – Hueco Jan 10 at 0:32
• The intention is to exactly match the exposure between two images. Eventually the frames would be used in a video, so any error would be very visible as flickering. – James Voss Jan 10 at 0:41
• You're not trying to match exposure. You're trying to match image brightness. Those are two very different things. Exposure is strictly the value of the combinations of sensitivity (ISO), aperture (Av), and exposure time/shutter speed (Tv). A given exposure value has nothing to do with how bright the scene is or how bright the result is.You can shoot under bright sunlight at ISO 100, f/2.8, 1/2 second and in a very dark cave at ISO 100, f/2.8, 1/2 second. One image will be pure white, the other will be solid black. Both were shot at EV 4. Both have the same exposure. – Michael C Jan 10 at 4:01