RT Would someone be so nice to explain to a stupid (me) a couple of things (retinex/dehaze)

Hi to all.
i read rawpedia, i tried to figure it out myself but i don’t understand how retinex work and how use it to dehaze a photo.
could/ would someone explain to me how use it correctly? Like to a 3 yrs old cause seems i’m too stupid to understand it.
a step by step case would be fantastic

_DSC4138.NEF (19.1 MB)

i add a photo of an example i would like to dehaze.
Thanks for any help.

Maybe @jdc can help.

Why use Retinex?
According to Dan Margulis (Author of the book ``The canyon conundrum and other adventures in the most powerful colorspace’’), LAB eats through fog like blow torch through butter. Here is my attempt by doing only L ,A, and B curves adjustments in the LAB tab of RawTherapee.
_DSC4138.jpg.out.pp3 (10.0 KB)

What do you think?

1 Like

I claim neither to understand it correctly, nor to have a particularly satisfactory explanation on how to use it :slight_smile:
However, for dehazing I like what I get using the “low” method with a smaller radius and a larger contrast value. Here’s an example, I hope it can be of help.
(Besides retinex, I did some final tweaks with contrast by detail level and the ‘V’ curve of the HSV equalizer)

_DSC4138.NEF.pp3 (10.5 KB)

that i’ve to buy that book, cause is interesting, (best title ever), :joy: i think i could learn a lot from that, lab is a world, and i use it at is bare minimum (luminance correction)

I absolutely love your result.

I somewhat managed to cure it in other way (contrast and tone,) not a s good as yours, but i choosed this shot on purpose, is a photo that could be corrected in different way, with decorous results, i suppose in retinex too.
I could not correct this image in retinex. (a total disaster) and retinex is an interesting tool, pretty powerful, but i do not, understand the tool, i do not understand it at all, reading rawpedia i feel myself an idiot.
so have an explanation, using a workable photo, with maybe some information on how it works, for a dummy, would be fantastic for me.

A sidenote:
I’ve got a strange relationship with RT, love/hate, so much power so much possibilities, but i get lost into the tools it gave me, (or at least part of them, retinex, wavelets… in part from the information are too complex , (not author fault my fault) and a part from lacking of tutorials, (dumbed down ones) that could help me out, but i suppose not only me to learn truly, this amazing software.

Alberto, we end up with the same troubles,(u less than me)
on the first plane, retinex regive us info from the shadows, if u look at the trees on the right u will notice, that we got a “bitmap” effect, we have reduced the mist but at an really high tradeoff for.
and as retinex is aimed to work a bit as lightness of human vision, something is wrong.

in my ignorance i think could be something i do not understand on how allow retinex mask correctly the image…

eg an interesting article (i do not understand the math but i’m watching the images :smiley:
http://www.cs.huji.ac.il/~raananf/projects/dehaze_cl/results/index_comp_noise.html

or maybe i’m trying to use the wrong tool at all and retinex would work for regain info from shadow, but is not correct to get the rid of fog, and i’ve misunderstood the tool at all, but here they talk about retinex for dehazing

http://www.programering.com/a/MjM5cjNwATc.html
so i get lost how to use it in rt i got a tool but do not understand how to use it :smiley:

Thanks @graypixel .
Many tools perform the same job with slightly different advantages/disadvantages. I have learnt over a period of time to focus only on few tools of RT and keep reading this forum for new information regarding other tools and their usages.

The tools I use always are following:

  1. In the color management tab, load the profile of the camera and enable all options.
  2. If the ISO is above 800, change the demosaicing to Immse.
  3. (After reading the book on LAB), check the LAB curves for possible improvements.
  4. Go to Wavelet Levels tab and use (if needed) Denoise and Sharpen tabs and always experiment with Residual Image tab.
  5. Go to Color tab again (if needed) and try various film simulations.
  6. Occasionally, use the vignette tool in the crop section to either lighten or darken the edges.

I am very happy with results of this workflow. If further local tuning is required, I do it in GIMP with the help of great G’MIC filters.

BTW, here is a hint about manipulating A and B curves. Make sure that the curve passes through the centre point of the square. That keeps the white balance as in the photo. If you want to change the white balance then just shift the curve off that point.

Hope I have not bored you with too many trivial details. Cheers.

1 Like

absolutely not bored and i thank you for the information… i would look in depth the pp3 too

Excuse my bad English, I’m a grumpy old French.
I like to develop algorithms, some are simple, like Lab, others more complex like Retinex, others even more like Wavelet, or Locallab.

But actually, there is a lack of tutorials (and translation from french in some cases) for Rawtherapee, especially for algoritms that come out of “common sense”, such as Retinex, Tone-mapping or Wavelet.
Wavelet does not limit itself to a restricted view which consists of using only the contrast sliders.
Many innovations “wavelet” , especially for this image, can be used to reinforce the effects of contrast and perspective,
for example “Residual image” and “Final touchup” (compression, contrast balance, etc.)

Paradoxically I am not a treatment specialist: what treatment for such an image? So it’s not me who will develop the tutorials
But the result is above all a matter of taste :slight_smile:

I agree that there are trade-offs with retinex (as with any other tool), and of course the result is also a matter of taste. I was trying to do this with retinex, as I took your question as an excuse to learn (by experimenting) about it myself :slight_smile:

FWIW, I usually do this kind of processing with the tone-mapping tool, not with retinex. Though I’m not guaranteeing that you will like the result any more than my previous attempt :wink:

tonemapping.pp3 (10.1 KB)

alberto as i said u obtained a truly better result than me, and i’m thankful for your help i would lurk from your pp3 too and grasp some info from. if u give a look of the couple of link i posted u would see that retinex could do amazing thing, and i’m sure the implementation on RT could do the same, the thing is How…

Jdc, u give us a wonderful set of instruments, and in rawpedia there’s the explanation, and eg for wavelet is pretty extensive… but are too complex, to grasp (at least for me), without something simple and stupid, to follow.
The taste in the result is ininfluent in this case the scope is not have a pretty picture is understand a tool.

Ihmo is matter of have a basic example of how the tool work in order to understand it. And not playing in an empyrical way, a base to start from, the floor. where to put feet on.
EG:
As example in the link below we have, input various method, (unexplained) but i could grasp how it works, (the mask).
Non-Local Image Dehazing

In our case with Retinex (could be valid for everything)
I fatigue to find someone better than you that could make a basic example, input–>result, and at side the explanation of the parameters, and why,
is like teaching 1+1=2 to someone that do not understand the simbol 1 done with a couple of apples became more easy.

I understand that you could have, nor the time, or the patience or the will, you are already doing a lot of work, but is a pity, some instruments into rawtherapee are there, but are much more less used cause not undestood, and if u notice there’s just googling, when we come to rawtherapee that could blow out of water almost 90% of other software out there, there’s few too few or no tutorials on the advanced tools…
cheers.

The tool in RawTherapee which is now called Retinex was originally called Dehaze. I too am curious as to how it could be used to remove haze from the distant parts in the middle of this image without significantly affecting the rest.

@graypixel
You are not at all stupid, nobody is stupid, I recognize - the reproach has already been made - that the explanation I give for Retinex, as for Wavelet better explains the algorithm (how it works, its principle, … ) than its operating instructions (what to do, what to do to obtain a result).

Some time ago, Paul (Paul Matthijsse) started a process of developing tutorials, but for some time I have not seen anything new.

I will try, on a more significant example than the one you give, to describe an approach, but I do not guarantee anything. I would do it in French.

To be complete, I would also use “retinex in wavelet” in branch “Newwaveletgtk3” which is almost “dead” (no comment) for 6 months

@Morgan_Hardwood
To deal with what you are talking about, there is “locallab Retinex”

Jacques

@graypixel

Don’t worry about it. Everyone has to start somewhere. I often feel the same way because for much of my life I have been around terrible people who say and do terrible things.

But you know what? When you continue to ask questions and investigate, eventually what you are pursuing will make sense. I believe you will figure this out with the help of the good people here.

Also, you need to be super hands-on. Until you get a feel for it, like riding a bicycle or anything really, any amount of theory won’t help you.


You are on the right track by reading papers online. However, they tend to be, well, scientific and esoteric, which is hard to understand from an intuitive level.

  • Before doing that I suggest that you do a quick search on this forum. If you type “retinex” or “haze”, you will get lots of threads and posts that ask very similar questions. E.g., my post.

  • A website I enjoy is http://www.ipol.im/.

It is excellent because its papers are quite simple in comparison to the meatier ones that you have linked to. Each paper comes with a demo and its source code, which you can play with at your leisure.

Take a look under the “Color and Contrast” topic category. Don’t just look at “retinex” but read the other papers as well to get a better understanding of the topic.

Hope this helps.

Applied neutral profile, and adjusted exposure (+1) just to stretch the histogram. I think it is important to start with Retinex first before other manipulations. Previously I have applied Retinex after my usual edits, but always found it a bit too much and have ended up reducing strength to very low values to control it.

Then switched Retinex method to highlights, HSL-linear.

Then applied a contrast curve to darken the darks back to normal.

Then reduced LAB chromaticity to taste.


_DSC4138.jpg.out.pp3 (9.6 KB)

3 Likes

@graypixel, I tried to understand what are various tabs in the Retinex tools are. Here is my first approximation to an understanding :grinning: Please let me know of my mistakes.

Method: High, Low and Uniform signifies the size of areas this tool will operate on. Therefore, the Low method will act on Foliage and small details and High method acts on broader areas like the sky or the town (in this example). In your example, we do not want to tamper with the green foliage so choose High method.

Strength is self-explanatory!

Radius also decides the size of details on which this tool operates. (So choose high radius)

This choice of Method and Radius automatically determines a mask which will be applied to the image and the tool is only applied to the white part of the mask.

Contrast slider seem to do the opposite of what one expects. The lower it is, we seem to get higher separation between low and high tones. (Does it act on the mask rather than the image?)

Process gives choices between seeing the image as it changes (Standard) or the Mask (genertaed above) together with Gaussian Blurr applied (so the edges are not sharp) or the mask with wavelet tool applied. We can further tweak this mask by the mask equaliser curve (which is just like the curve tool on luminosity.

By choosing to see the m ask in the Process drop down menu, one can see how the mask changes as we adjust the luminosity curve.

The Highlight slider protects the highlight with the width of highlight being determinable by the next slider. Same with Shadows slider.

After this we get the L curve adjustment (Like in L,A,B tab) and we can further add contrast by making the curve steeper. Then we have a tone mapper added to it (very thoughtful!)

I am yet to figure out the Transmission tabs.

Now, with this understanding (right or wrong!!!) I applied the following Retinex setting to get the following image. I have uploaded a higher resolution image so you can enlarge and see for artifacts.

_DSC4138-1.jpg.out.pp3 (10.0 KB)

Of course, before all this, I applied the D300 profile in the colour management tab.
Thanks for the image. It pushed me to overcome my inertia about understanding Retinex. Now if only I could read French :grin:

1 Like

@graypixel

I don’t use RawTherapee, so I am a beginner just like you. But I was curious about its implementation, so I gave it a try. Takeaways:

  • It is always helpful to toggle Before/After. I also zoomed in, enough to see the details but not to the point where I cannot see the overall composition.

  • Read the tool-tips. Hover the mouse over things and a tool-tip pops up to give you info about the control. The tool-tips are surprisingly detailed. Good job RawTherapee devs.

  • Unlike @shreedhar, I found Method:Low to be good because it heightens the detail of the far off city, which I like. I guess it depends on taste; which areas you want to emphasize.

  • Process:Transmission reveals the transmission map, which is what is going on behind the scenes under settings. This will allow you to observe what changes as you tweak the controls and curves. Through experimentation, you will begin to understand what works for you.

  • Transmission maps are like it sounds. Ask yourself this question: If conditions weren’t hazy, where would the light be? If you took this picture (I like it btw), you would have a good idea. The usual reason that retinex looks funny is that we tend to want to equalize everything.

These points are just from my experience. If I am wrong about something, someone please correct me.

so the "rt implementation of retinex could not give us the total removal of haze, like fattal algo or true algo.
ok i’ve to install the local lab version a step ahead :smiley:
Jdc in French in spanish in japanese :smiley: google translate help always.
Apart from jokes thanks, even for the i would look into doing that, i understand that would be an effort do that, and that u could not guarantee anything.

then, with james and shreedar we are are almost there, shadows a bit uplift but not “bitmap effect”,i’ve got an idea of workflow thanks to all you tomorrow i would try out and report… :smiley:

Afre if u give a look on rawpedia u will discover that retinex have a lot more to offer.afre i u could share you result,
only one thing, the scope the help i asked is in this case is understand how to remove haze with the aid of retinex mantaining the photo usable, taste is a bit secondary, cause once remove dthe haze we could think about of how make the photo pretty, if we manage to get the rid of the mist we would have a common starting point,

the trasmission is the key, how to manipulate that mask, correctly… for the result…

where would the light be? for that photo to be honest is right were is :smiley: i choosed that photo cause could be corrected, not cause really need to be cured, and could be prettier in various way, as shreedar have demonstrated using only lab curves.
I thinked this photo would be decent cause is not too badly exposed, the fog is more on the second plane, so a “standard” condition for a “dehaze”.
Retinex by definiton of the thing could work for a lot of different scenarios not only with mist or fog, with lights… recovery of part of a photo from deep shadow. think about concert or other much more harsh condition where this tool could be really useful once truly grasped.

ps thanks for the like of the photo, is one of a row, for a pano,. when finished i would post it here

@shreedhar
This is a good summary :slight_smile:

jacques

1 Like

_DSC4138.NEF.pp3 (10.7 KB)
The goal here was to see more of the rooftops and forest, so I cropped it down. Retinex and negative tone mapping were applied, other adjustments made to lightness, contrast, Lab* color effects.

The haze tends to de-contrast the offending area of photos, so I use a high radius shadow mode burn tool (a shadow deepening effect) in McGIMP…

Followed by highlight dodge (a highlight brightener).


This way I notice less haze and more roofs.