本文只记录在调研banding算法过程中看过的一些源码和论文,不做系统的整理和性能评估。比较潦草,欢迎大佬补充指正。
应用场景
banding artifacts 通常产生的原因:
- 视频编码量化
- 增强算法(如 color tone mapping,对比度增强)增加了相邻区域的色阶距离
传统方法
dither
搜debanding提到的比较多的一个方法就是dithering,基本原理就是给图像添加一个随机的像素偏移,相当于用随机噪声cover掉了banding效果。
由于dither在编码时容易被抹除,因此最好的方法是加在playback端
ffmpeg filter
ffmpeg中有两个debanding filter
deband
ffmpeg -i input.mp4 -vf deband output.mp4
ffmpeg -i input.mp4 -vf gradfun output.mp4
速度上gradfun略快,主客观效果暂无测试
paper
记录一下看过的两篇paper
- Advanced Video Debanding
传统方法常用的debanding步骤
- Detect regions of banding. Since banding is most visible on smooth gradients, they usually look for low-textured regions of the picture.
- Undo the quantization and restore the original aspects of the image(比如映射回浮点数或者使用更高的比特数). This is done by applying a smoothing process to the degraded picture and thus removing the banding discontinuities.
- Finally, in order to match the screen bit depth, quantization needs to be reapplied. However, this time, a dithering process is used, which adds a noise pattern to create the illusion of a smooth gradient
现有方法的不足:
Unfortunately the existing approaches are limited, either by the level of quantization they can deal with, or by the picture quality they can achieve.
本文提出的banding检测和评估方法
将相同RGB值的像素点连通成局部区域(块),可以看到,有banding现象的视频,块尺寸较大。因此将块大小的分布作为banding强度的index。
pixel banding index公式
曲线,画出来是这样,相关阈值的设定见paper
接下来,是修复banding的方法,基于以下几个observation- 相同banding块中的像素点,其原始像素值不能偏离当前块像素值太多,
- 原始像素值受相邻块影响(其实就是相邻块做一个线性插值)
- 相邻块越大,对当前像素点影响越大(基于块大小计算权值)
distance使用到相邻块最近像素点的距离。
最终计算权值的公式
最后,为了防止再次量化产生的banding,加入dither,dither矩阵:
评论:
无参考的banding检测还是会产生误检的情况,把一些人为的色块边界smooth掉,所以针对我们的使用场景(处理增强产生的banding),还是使用有参的方法会好一些。
dither这一步一般适合加在量化后或者playback的时候,我们暂时不考虑
- Adaptive Debanding Filter
这一篇是2020年SPL的论文,对现有的banding检测和处理方法做了还不错的review
banding的检测:
使用了基于canny算子的检测手段。通过计算梯度,用两个阈值将像素分为三类,flat pixels (FP),candidate banding pixel (CBP),textured pixels (TP)
banding的消除使用了boxblur,kernel大小随band大小自适应调整
kernel 大小计算公式,band面积除以相邻边长
对于窗口中存在tp(texture pixel)的,将kernel大小迭代减半。texture pixel也是通过梯度判定。
评论:
全文来看创新性并不多,对于纹理的保留也是手动设定梯度阈值来实现。
目前看到的方法来看,原理基本差不多,使用低通滤波处理banding边缘,后处理加dither防止banding复现,对于不同强度的纹理区分处理
待更新
一篇banding检测的论文
A perceptual visibility metric for banding artifacts