Skip to content跳到正文
All work全部作品

2023 · AI人工智能

Low-Light Underwater Image Enhancement with L²UWE用 L²UWE 增强低光照水下图像

A Python reimplementation of L²UWE, a method that brightens dark underwater photos using local contrast and the physics of haze, with no training data. I rebuilt it from the paper alone, supervised by one of its authors, and tested it on more than 100 deep-sea images.用 Python 重新实现 L²UWE。这种方法利用局部对比度和雾气形成的物理原理,把昏暗的水下照片变亮,不需要任何训练数据。我在论文作者之一的指导下,只凭论文把它重写出来,并在 100 多张深海图像上做了测试。

Low-Light Underwater Image Enhancement with L²UWE
Underwater images tested测试的水下图像
100+100+
Training data needed所需训练数据
None无
Rebuilt from重写方式
MATLAB to Python从 MATLAB 改写为 Python

Why I built it

Photos taken deep underwater come out dark, hazy and tinted, because water absorbs and scatters light. L²UWE, published by Tunai Porto Marques and Alexandra Branzan Albu in 2020, brightens them without any training data. It works from local contrast and a model of how haze forms.

The original was written in MATLAB. In 2023, supervised by Professor Albu, I rebuilt it in Python from the paper and its equations alone. I wanted to understand the method from the inside, one step at a time.

How it works

A dark underwater image, once inverted, looks a lot like a photo taken in fog. So the method inverts the image, removes the “haze” with the dark channel prior from He et al., and inverts the result back.

  • Contrast code image. For every pixel, the local standard deviation is measured over windows from 15×15 down to 3×3. The size where contrast settles becomes a code from 1 to 7, so busy areas and flat areas get different patch sizes in every later step.
  • Dark channel. The darkest value around each pixel, over the patch its code chose.
  • Atmospheric light. Estimated locally from the dark channel, in larger patches, then smoothed. A single global value is too crude for scenes lit by a diver’s lamp.
  • Transmission map and recovery. How much light reaches the camera from each point, which then gives back the scene without the haze.

The paper runs this twice, with small patches for detail and large patches for brightness, and blends the two with multi-scale fusion. My 2023 version followed it through the fusion. The version on GitHub is a cleaner rewrite that currently covers the small-patch branch, and it produced every image on this page.

为什么要做它

在深海拍的照片往往又暗、又朦胧、还偏色,因为水会吸收和散射光线。L²UWE 由 Tunai Porto Marques 和 Alexandra Branzan Albu 在 2020 年发表,它不需要任何训练数据就能把这类照片变亮。它依靠的是局部对比度,以及一个描述雾气如何形成的模型。

原版是用 MATLAB 写的。2023 年,我在 Albu 教授的指导下,只根据论文和其中的公式,用 Python 把它重新写了一遍。我想一步一步地从内部真正弄懂这个方法。

工作原理

一张昏暗的水下图像,把颜色反转之后,看起来很像一张在雾里拍的照片。所以这个方法先把图像反转,再用 He 等人提出的暗通道先验(dark channel prior)去掉“雾”,最后把结果反转回来。

  • 对比度编码图。 对每个像素,在从 15×15 到 3×3 的窗口里分别计算局部标准差。对比度趋于稳定时的窗口大小被记成 1 到 7 的编码,这样在后面的每一步里,细节多的区域和平坦的区域会用不同大小的图块。
  • 暗通道。 每个像素周围、在其编码所选图块范围内的最暗值。
  • 大气光。 根据暗通道在更大的图块里做局部估计,然后再做平滑。对于由潜水员的灯照亮的场景,只用一个全局值太粗糙了。
  • 透射图与复原。 透射图表示每个点有多少光能到达相机,有了它就能还原出去掉雾气的场景。

论文把这个过程跑两遍,一遍用小图块保留细节,一遍用大图块提升亮度,再通过多尺度融合把两者合在一起。我 2023 年的版本一直做到了融合这一步。GitHub 上的版本是一次更整洁的重写,目前只包含小图块这一支,本页所有图片都是用它生成的。

Six stages of one image: the input, the inverted image, the contrast code image, the dark channel, the transmission map, and the recovered result

Results

I tested it on more than 100 images from the OceanDark and USR-248 datasets. Scenes that were almost black come back with colour and detail you couldn’t see before, like the sea urchins in the top row below. On the image I scored with the PUIQE evaluation platform, all three of its metrics (UCIQE, UIQM and CCF) improved.

结果

我在 OceanDark 和 USR-248 两个数据集的 100 多张图像上做了测试。原本几乎全黑的场景,恢复出了之前看不见的颜色和细节,比如下图第一行里的海胆。在我用 PUIQE 评估平台打分的那张图像上,它的三项指标(UCIQE、UIQM 和 CCF)全部有所提升。

Three underwater scenes before and after enhancement: sea urchins on the seafloor, a group of sharks, and a coral-covered frame that turns greener

Where it falls short

Scenes that are already green come out greener, as in the bottom row. I noted it in 2023 and never found the cause. In the darkest areas the method also brings out JPEG compression blocks along with the detail. And I didn’t compare it against other enhancement methods, so these results show what it does, not how it ranks.

Test images are from the OceanDark dataset.

不足之处

本来就偏绿的场景,处理后会更绿,就像最下面一行那样。我在 2023 年就注意到了这一点,但一直没找到原因。在最暗的区域,这个方法在带出细节的同时,也会把 JPEG 压缩产生的方块一起放大出来。另外,我没有把它和其他增强方法做对比,所以这些结果只能说明它的效果如何,不能说明它排在什么位置。

测试图像来自 OceanDark 数据集。