darktable-org / darktable

darktable is an open source photography workflow application and raw developer
https://www.darktable.org
GNU General Public License v3.0
9.53k stars 1.13k forks source link

Enhanced dehazing algorithm (with new code) #10127

Closed weltyj closed 1 year ago

weltyj commented 2 years ago

First I'll pre-apologize for not being GIT trained enough to do this myself.

I have a little write up of an enhanced version of the haze removal tool (attached).

I simply overwrote the previous src/iop/hazeremoval.c with my changes, which is attached. But I think you'd want a whole new module name if you think it's worthy and I have no idea how to do it. I don't have opencl versions of the algorithm, and am probably not the person to attempt it.

I've been using this over a year now and am pretty happy with it, but it is in need of some help from someone who knows darktable coding protocols well (which is not me).

I'll be happy to help in any way my skill set will allow :-D

Cheers, Jeff Welty An updated algorithm for haze removal.pdf

hazeremoval.c.txt MoreDehazeExamples.pdf Screenshots_ehanced_module.pdf

TurboGit commented 2 years ago

Can you post some screenshots of the difference on real pictures with current module ?

weltyj commented 2 years ago

I'll get some screenshots. It's a little tricky for me because all my .xmp's now have more parameters for haze removal, and darktable will detect the change of parameter count and reset parameters for haze removal in my .xmp's even in lighttable mode as I recall. But I think I can just create a new linux account, recompile for the current module and run a few images there so my current account darktable database won't get altered and there will be copies of the .xmp's in the new account. The example in the PDF does use the old algorithm for determining haze color (I just modified the code for that one shot and did a quick recompile and did the screen capture.).

weltyj commented 2 years ago

I have edited my original post and added two more pdfs -- one with more side by side examples of the current module vs the enhanced module, and some actual screenshots of the enhanced module.

TurboGit commented 2 years ago

This will require comments from more knowledgeable on image processing than me. But some points:

weltyj commented 2 years ago

Thanks for looking this over!

Some answers to your points:

This module does operate in RGB mode. I only use the LAB values for the haze color adjustment because it was extremely difficult to adjust the haze color as seperate values for R, G, and B. I had to copy some of the RGB2LAB and LAB2RGB code to apply the haze adjustments (not computationally expensive as it is just a single RGB value that is modified), but I'm sure my hacked code is not the way it should be done.

The gamma control is not what you'd think of as normal gamma, it is applied to the transmission value immediately before the dehaze calculation and cannot be removed. Renaming it to avoid confusion is a good idea I think ;-) Actually renaming all of the controls is certainly worth discussion.

The only controls that are independent and could be separated from the dehaze algorithm itself are the desaturate -- which could be done with a parametric filter and the contrast-brightness-saturation module, and the exposure adjustment. I'd argue it is much, much quicker for the user to leave those controls in place rather than the user having to create or enable those modules, position them in the processing chain immediately after dehazing, move back and forth between the modules making adjustments until the desired affect is achieved. That being said, from my experience, the exposure correction is infrequently used, but the desaturate control is almost always used.

github-actions[bot] commented 2 years ago

This issue did not get any activity in the past 60 days and will be closed in 365 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 300 days with no activity. Please check if the newest release or nightly build has it fixed. Please, create a new issue if the issue is not fixed.