Dehaze started failing after recent update

After updating my pc this month, the dehaze module started saying:
“Haze removal could not calculate ambient light due to image content”.
I do mass product photography and use dehaze on images that realistically don’t have haze, as they’re shot in a controlled environment.
Even then, I use dehaze as prefer how it brings back contrast over regular contrast tweaks. I use it only lightly, and it removes light spill from our photo table.
For past few years I never got this message, only now for the first time I saw it appear on certain images.
Here’s one that fails to dehaze:
P1036523.RW2 (34.4 MB)
P1036523.RW2.xmp (14.9 KB)
And proof it fails to dehaze on my setup:

I’m on arch/endeavouros, darktable v 5.4.1.
I don’t really care for the realistic “haze removal” of it, I just expect it to do the contrast thing and that’s it, so I never considered even it could fail.

What can I do in this situation? Thanks, dj~

update: it seems it failed on almost all of my photos? Never seen this happen b4. Did it actually never work in that case, but failed silently?

1 Like

You are “misusing” the module, see comment in Haze Removal causes highlights to blow out after export · Issue #19069 · darktable-org/darktable · GitHub

1 Like

I understood as much…
Then how would you recreate the effect it provides with more intended tools? I don’t think it’s effect is as simple as more contrast in highlights through local contrast and contrast equalizer

No it isn’t as simple as just applying contrast in LC or CE modules. I find that I often need to bring midtones down a tiny bit and shadows up a tiny bit, then add extra saturation/chroma to both. Then, I use the dehaze in Diffuse/Sharpen -default and adjust the “edge threshold” up a tiny bit and reduce the iterations a couple points. But it is never exactly the same.

If you need to reproduce things because the fix broke your edits, you can usually crop way down on the file and the Dehaze module will work again. Take a snapshot, then on another copy play until you get close to a match. If your images are all very similar to the one you posted (just different yarns), you could probably save it as a preset and apply to the other images.

Your image does not have a license, so I won’t post another one. Here is the xmp for a cropped version that enables Dehaze as a starting point:
P1036523_cropped.RW2.xmp (15.7 KB)

1 Like

As I understand the history of the module (source hazeremoval.c) old edits should not be broken.

My understanding :
To function properly, the module calculates internal parameters based on the image content. If this calculation fails (no haze to remove, large dark or black areas … , calculated parameter(s) fall(s) outside the permissible range), a warning is shown since May 18, 2025 (commit b179cb2) instead of silently failing.

1 Like

I must have boneheaded something elsewhere in my printing pipeline, and attributed it to dehaze. I have only seen the warning once (and dont use the module anymore), so never did a deep dive.