I want to dehaze a photo with Retinex

Last year on the old forum,a user suggested that file as an example to Dehaze

Madeira to dehaze

It’s a very difficult image, with with significant haze, and many local contrast

1 Like


  1. Only the sky in this image is overexposed. This day was very hot with a sky uniformly white, very luminous with no detail inside. In this case taking a photo is a desperate case.
    The haze is thus so important that the details on the background are obfuscated.
    I hoped dehaze could restore some detail.

  2. despite your indications, I could get no improvement. So I will try on an other photo with normal sky.

  3. you provide an explanation of transmission map in algorithmic term. As I understand it from use of dark channel prior soft, it is a representation of athmosphere thickness between object and camera. If you have a look at the mask provided in the link, you will see in black the location of foregroud, in white the background and grey intermediate locations. I cannot understand how to dehaze if first you dont generate this kind of mask.
    remark : as for a luminance mask there is no detail in it. That mask is a transmission mask.

  4. the construction of the transmission mask should require no parameter adjustment from user (automatic generation). After that the mask could be modulated by a luminance curve and perhaps some strength parameter applied for the processing itself.

  5. If there are parameters required due to the (bad?) location of Retinex in the pipeline, they should be identified and gathered in the GUI.

  6. I just have a look at paper “automatic Image Haze removal…” cited by you. Is it what you implemented?

Thank you for your answers.


  • “automatic Image Haze removal…” is the first contact I have had with Retinex, this was the starting base : with the parameters by default you have and automatic process…

  • the construction of the transmission mask is automatic…but depends from parameters upstream (nature of the image, sigma (radius), type of method [low, high…], scale…)…it was only after that we can work on it (contrast, threshold, curve…)

  • you ask me how it works…So I answer

5 - I don’t understand what you want…RT is made like this, and touch the internal pipeline undermines everything. To date the only process we did escape this rule is Retinex. All that is “removed”, according to the images, may play a role (White balance, Highlights, RGB conversion (gamut), exposure, RGB threatment,…)

1 Like

Hello, just for information. I saw that strong pink cast as well when using the ‘normal’ Retinex tool under the Exposure tab in RT. But then I tried the new retinex tool in the wavelet section (that’s in the newwavelets (development) branch) and that gave the following result. Not bad as a starting point, isn’t it?

Thank you for the tip.
It seems effectively much better with an effective dehaze on th backgroud.

But it is not a true dehazer as there is also an effect on the foreground (see the trees at bottom left).
As we know the haze is due to the thicknes of athmosphere, there should be no effect on foregroud object. This modulation of effect is performed through the so called transmission mask : it is a kind of alpha mask

My attempt, using the normal Retinex tool. I don’t know what is expected of the result, can other software do better?

(I had my monitor profile applied so it might look weird on your end)

PP3: http://filebin.net/88ddc41c5f

What are we trying to do here, are we trying to see more features or to make the photo look good? I don’t think it makes much sense to test Retinex on this photo. It suffers not just from haze but also from terrible light, lens flare, etc. It’s the kind of photo I would delete. You can use software to make details more visible but it won’t ever look as good as if it was simply taken during a better time of day.

Thank you for your proposal
As I wrote in my first post, I didn’nt want either to test retinex, to make the photo look good or to compare rawtherapee with other SW.
The modest objective I have is only to understand how to use Retinex to dehaze a photo and to have an acceptable parameter set for that.
Reminder : this fonction was the origin for implementation of retinex by Jacques.

In those conditions, I think the quality of photo is not very important (flare, distortion or other defects), but perhaps I am wrong. I took this photo as a first mean as it had a distinctive foreground and background.
The principal effect of dehazing is to modify luminance depending on the distance of object.
It is thus possible to dehaze the background without modifying the foreground.
That doesn’t seem possibe: in your trial, the foliage is quite modified, becoming weird, though of course there is no haze here.
I am going to study your proposal, but now I think the dehaze function is not completely implemented, even if Retinex is fully functional.
Thanks again

@gganed92, How did you create this mask?

@paulmatth, What’s behind those New Wavelets?
Are those from Dark Table?

@Royi, with newwavelets I was referring to a development branch of RawTherapee. In the main branch (the software you can download left and right) there is already a tool called wavelets.
Have a look at my site if you like (more articles on this in the menu on top, RawTherapee - Wavelets).

Wavelet processing in RawTherapee

@paulmatth, Is there a place to read about the “New Wavelets” (Is there a Forum dedicated to the development)?
I see the current are based on classic Wavelets.

I’d like to play with math of Wavelets a little bit.

Thank You.

@Royi Wavelet Unsharp-Mask and Clarity - newwavelet branch · Issue #2982 · Beep6581/RawTherapee · GitHub

Hello, tryong to respond by phone. Yes, you can read a bit about the newwavelet development via the link given above to github. Pose your questions directly to Jacques Desmis, who made the wavelet tool.

Second. No, there’s no forum dedicated to newwavelets, nor documentation for the moment. See for yourself if it works for you, if yes, consider writing a little manual.

One more thing. Current wavelets are not classic wavelets but current wavelets. The new one offer some extra things, that’s all.

Royi noreply@discuss.pixls.us a écrit :

This transmission mask is made with a dehazer plugin from Kolor based on dark channel prior algorithm. I sometimes use it with xnview to create the mask and export it in GIMP. You can then make corrections on background (luminance, blue cast, sharpening) without risk to destroy foreground.

You can find “newwavelet” win32 build at RT WIN32 builds

How do you know it is based on Dark Channel Prior algorithm?

Thank You.

Any idea where I can find the dehazer plug-in?


Thanks Morgan. Much appreciated.

I’m not familiar with dark channel and wavelets and such, so googled earlier and found this paper from 2009
Perhaps some of you know of it, perhaps it is what’s in RT. I recommend it, there are comparison photos with other de-haze methods (and lots of maths). I found it interesting, didn’t realise you could “cut through the noise” like that. Perhaps naïve - I suppose the spy satellites have been doing it for ages?.. I’m still so impressed with how much is in RT (though need to sort out a better system, my 32bit Win7 easily crashes).

[quote=“RawConvert, post:21, topic:733”]
I suppose the spy satellites have been doing it for ages?..
[/quote]I have not worked on spy satelites (and if I did I probably couldn’t say so). But in general the ‘dehazing’ applied to satellite photos is more simple because the distance of the imaged points is practically very similar so you can get away with subtracting a uniform (or at least low frequency) value.

I explored dehazing algorithms a bit in the past and it looks like a nice problem to work on. I’d love to explore it once I find time for it.

For now the best solutions I found with existing FOSS software was with darktables equalizer (similar to the wavelets in rawtherapee) and some selective color adjustments. You can find this described here: Dehaze equivalent in darktable or RawTherapee - #13 by Jonas_Wagner I’m fairly sure the equalizer part can also be done in rawtherapee via wavelets (minus the masking). I’m not sure about the local color adjustments.

1 Like