# A question on Exposure compensation

Hi all!

I am trying to get a better understanding of what exposure compensation exactly does at the pixel level. What mathematical operations are operated on every pixel and where can I find the formulas? From the documentation (https://rawpedia.rawtherapee.com/Exposure#Exposure_Compensation) I see that a gain is applied. If there is only a gain applied to each of the color channels, what losses will be actually made if you decide to first compress the raw image to jpg, and then do the “gain adjustments” on the pixel? How much would that differ from first doing the exposure compensation on the raw image and then doing the compression to jpg?

regards

It should be this

``rgb_linear_new = rgb_linear * ( 2^Exposure_compensation)``
2 Likes

It would be a simple multiplication if it weren’t for those pesky stops…

1 Like

The jpeg is nonlinear (alrealy processed to be pleasing when viewed) so you can brighten or darken the image in a general sense, but you can’t do precise exposure compensation.

Additionally, the jpeg throws out data that doesn’t affect the way you see the image when viewed normally. By manipulating the image, the resulting compression artifacts may become very noticeable.

2 Likes

What do you mean with pesky stops?

Thanks for mentioning this. Are there linear ways to reduce the size of the raw image within Rawtherapee? Should be right? I was thinking of something like reducing the number of pixels by taking the average of neighboring pixels.

A stop (EV) is a doubling or halving of the exposure. So +1EV is x2, +2EV is x4, etc. That’s why the equation shown by @age has the ‘2 to the EV power’ term.

If instead we quantified exposure as the multiplier, the equation would just be a multiplication.

The math operation used to do this in image resizing is ‘interpolation’. A simple average doesn’t look so good, so more complicated equations are used, with names attributing the authors, like ‘lanczos3’ ‘catmull-rom’. Interpolation is a rather pervasive algorithm in image processing, used in resizing, lens distortion correction, and lookup table processing, to my direct experience.

Fun fact: ‘catmull’ refers to Ed Catmull, a former Pixar executive. In the movie Incredibles 2, I saw what appeared to be a plot of his interpolator in one of the montage scenes…

Very interesting! A lot of hidden references in movies haha.

So interpolation in rawtherapee is pretty easy I suppose? Is there an implementation of Lanczos method to reduce the size of raw images?

Never mind I already found it!

https://rawpedia.rawtherapee.com/Resize#Method

2 Likes