Improve Dehaze for Raw files

I created a Pull Request to take into account the improvement of Dehaze designed by Ingo in 2020.
Issue 5769

I only added “Dehaze” checkbox in Raw black point (Bayer and X-trans), and of course the whole process to update the sliders. (improccoordinator, rtengine, etc.).

I quote Ingo’s text to introduce this new concept

I made some tries with a very simple method to remove haze (and uniform lens flare) from raw files. Well, at least partly. It’s a good starting point to add the already existing dehaze tool in RT.

The method is super simple. It just calculates the mininum value from each raw channel and subtracts that value from the corresponding channel.

The idea behind this approach is:

If there is a region in the scene, which does not reflect enough light to the camera sensor, to be recorded by the sensor, then, if there is a sensor value > 0, this value must be caused by haze or flare and not by the scene.

Having this situation and assuming the haze or flare is somehow evenly distributed, we can just subtract it, and surprisingly, it works very well for long distance landscape shots, where there is a lot of haze between camera and subject, and maybe also a lot of flare (internal lens reflections) by using a long focal length which are more prone to internal reflections.

Of course we can not use this method for every image.

1. It does not work on high-iso files where the minimum value is always around zero because of noise
2. it does not work on underexposed files for the same reason

I just works for the conditions I described above.

Pull request Dehaze poordeha

Executables
https://github.com/Beep6581/RawTherapee/releases/tag/pre-dev-github-actions

Jacques

6 Likes

Original thread for those that are interested

Various improvements have been made to the process.

The result is unchanged - with the same limits mentioned: no overexposure, no underexposure, …

But the process is cleaner internally and (a little) faster, thanks in particular to the improvements made by @Lawrence37

Executables:
poordeha

Jacques

3 Likes

Hello

I just merge the Pull Request in Dev

Jacques

2 Likes

I just made a first test (RT 5.11-5-g1e0265f98).

When I open an image, the default values are:

After checking Dehaze:


Why are the sliders disabled after checking?

After unchecking Dehaze:


Wouldn’t it be better to set the values back to the values they had before checking Dehaze? As long as they are set on default (0,0,0,0) it’s no problem, but if they were changed manually, you’d better take a notice…
(Please don’t care about the checkbox green values, this is manually changed )

The effect on an image of a foggy Rhine (the dehaze values are other ones than displayed above)

Before:

After:

I think I have to play around with it to get a feeling for the usage.

From my side, it is very helpful to have the values of dehaze after disabling it again.

Usually, when activating dehaze, i get a result with very reddish darks and after this, these values are a good starting point to fiddle manually the correct blackpoints.

What i agree to:
a separate reset of all values at once, could be helpful. Now you have to reset each one by one. Such could improve also the work in other tools in RT.

1 Like

Didn’t think about that, but it’s a good point.

+1

I finally got around to trying the dev, and overall I like it. But I do question how it it is possible to dehaze an image if all 3 sliders (X-Trans) go into negative values which happens sometimes. To me, I can only ever see this scenario as adding haze not removing it.

Is it possible to block such a case via logic? I’m not sure what the user interface would be though.

Edit: here is a sample file. Using the dehaze function sets all 3 sliders to -15
DSCF0479.RAF (22.4 MB)
This file may used as needed for the development and testing of RawTherapee

Thanks for testing.

As a matter of principle, negative values are questionable in this case.

The principle developed by Ingo works well in most cases, with many reservations.

This is one of the reasons why this addition to the Raw Tab - which is not the most widely used - has a basic interface. It’s up to the user to see the relevance of the automatic settings. So a priori, I wouldn’t add anything to the GUI. :smiley:

Thank you again

Jacques

1 Like