[Custom CLI] For adjusting exposure (C++)

Hi all,

I have a custom workflow where I need to automate 2 tasks:

  • apply white balance from a spot (x, y coords)
  • tweak the exposure compensation until I get to a specific L value (Lab)

So far I managed to apply the white balance from a spot, and retrieve the L value from the same spot, but I get really big values for L (I am expecting 2 digit number and I get 4 digit numbers, Eg: expecting 64, and get 6300)

What am I doing wrong ?

Here I apply the white balance:

Here I get the L value from the processed image (from RGB)

Any suggestions are welcome, I did not write C++ since college so if you spot some things which can be done better please let me know :slight_smile:

The repo is public

I tested and built on linux in a docker container.

There’s an example photo in the input folder, which is mounted in the docker container.

I overwrote the main-cli.cc file, as I am not confident enough to mess with the CMake files :smiley:

The cli.cc file is mounted over the original main-cli.cc

To build it you need docker and docker compose:

  • clone the repo,
  • run docker-compose build
  • run docker-compose run app
  • run ./programs/rawtherapee/rawtherapee-cli ./input/IMG_0416.CR2 ./input/out.jpg

Ping @heckflosse or @floessie

@edcoreweb Can you post the console output please?

@heckflosse, sure please find the output below!

divide by 65535 instead of 255

1 Like

@heckflosse works like a charm, thanks a lot!

Everytime I change the exposure, I create a processing job and process the image. I have a hunch that this is not that efficient and very slow :smiley:

Is there a way to optimize this somehow, only to apply the exposure and not run all the processing pipeline again and again ?

@edcoreweb Please explain in clear words what you want to do. I currently didn’t get it (maybe because my brain isn’t working fully at the current high temperature here in germany…)
So please, try to explain it more simple. I’m sure there’s a better way, once I understood what you want to do.

@heckflosse sorry I was not clear enough, basically I need to adjust the exposure compensation until a ‘hard-coded’ point on the image reaches LAB (L = 79).

So, you have a reference point in our image which needs to be Lab L value 79?

1 Like

Exactly.

@heckflosse

My biggest problem is that, to get the RGB data of a point I need do have a processed image.

From my testing this is takes the longest.
An optimization I found is to crop the image 100 X 100 around the point I need to test.

But, there needs to be a better way to do this, without calling processImage every time.

My question:
Is there any way to get RGB from a point without calling processImage ?
Maybe only using the rtengine::StagedImageProcessor class ?

@heckflosse

Found a solution, not sure it’s the best, but basically I attach a Crop to the StagedImageProcessor and only apply the RGBCURVE bit mask when I change the exposure.

Thanks for your help, I owe you a beer.