Skip to content

Commit dde19d0

Browse files
committed
New Image > Lighting > Dehaze tool: ready for primetime!
Details in the comments! Let me copy+paste key details: Automatic image dehazing is an area of active study. It is of special interest to automative manufacturers, who need access to fast, high-quality dehazing algorithms for automative safety system cameras. PD's implementation is currently based on a 2018 paper in the open-access journal "Mathematical Problems in Engineering" by Zhong Luan, Hao Zeng, Yuanyuan Shang, Zhuhong Shao, and Hui Ding. The paper is titled "Fast Video Dehazing Using Per-Pixel Minimum Adjustment" and you can you download it here (link good as of September 2021): https://www.hindawi.com/journals/mpe/2018/9241629/ Many thanks to Zhong Luan et al for sharing their work under a Creative Commons Attribution License. I read quite a few dehazing papers from the past two decades before settling on this one for PhotoDemon's implementation. One of the biggest issues I have in PD development is implementing methods that meet a few strict criteria: 1) no massive 3rd-party libraries (e.g. OpenCV is out) or amd64-only libraries 2) good run-time performance without modern intrinsics, including SIMD (necessary for XP compatibility) 3) better performance than O(n^2) because considering (1) and (2), I still have to make the function fast enough to be useable on 20+ megapixel photos, even on PCs with strong RAM/CPU limitations. These criteria get harder to meet every year, especially as I attempt to add things to PD beyond the usual low-hanging photo editing fruit of brightness, contrast, etc. Anyway, I liked this paper because most dehazing approaches rely on either massive regional analysis on each pixel (which is incredibly slow), optimizing lengthy differential equations on-the-fly (which is even worse), or machine-learning algorithms that require huge training sets (ugh no). For example, this link describes a classical dehaze implementation based on the original dark-channel prior theory by Kaiming He: https://sites.google.com/site/computervisionadinastoica/final-project As the authors at that link state: "Running the algorithm on any larger images would require days of computation... He, Sun, and Tang mentioned using the Preconditioned Conjugate Gradient algorithm as a solver, allowing them to process a 600x400 pixel image in roughly 10-20 seconds." 10-20 seconds for a 600x400 image! Not gonna work for PhotoDemon. Convesely, the paper by Zhong Luan et al uses a much-simpler per-pixel analysis with good - and predictable! - results, excellent performance, low memory requirements, and many areas of potential further optimization that play nicely with VB6's limitations. Using this strategy, a 10-megapixel image processes in less than a second, regardless of inputs. Much better. As such, while this work is heavily inspired by the original paper, it is *not* identical. (Nothing built in VB ever is lol.) I have heavily commented the code to note deliberate modifications and/or enhancements, and I am open to input on further changes. As with other functions in PD, I generally try to err on the side of "more subtle, useful real-world results" vs "intense HDR-style changes" that look impressive in a paper but produce wildly unrealistic-looking results on things like regular iPhone photos. Ideas for further improvements are of course welcome.
1 parent 4f566dc commit dde19d0

File tree

2 files changed

+341
-51
lines changed

2 files changed

+341
-51
lines changed

0 commit comments

Comments
 (0)