最近精读了Jon Barraon的论文Fast Bilateral-Space Stereo for Synthetic Defocus。该论文使用bilateral Filter思想:将图像映射到bilateral space,滤波后再映射回pixel space,从而实现了双目图像(stereo images)的虚化效果。本文整理了该论文的基本思想分享给大家。
Fast Bilateral Filter
Bilateral Filter是一种经典的能够保留图像边界的滤波器,定义如下Wiki:
写成矩阵的形式即为论文中的公式(1), A 即为bilateral filter的权重参数。
由于bilateral filter计算量大,因此出现了各种快速解法,其中通过bilateral space来变换空间并进行操作的方法最多。即将像素点投影到bilateral space,在bilateral space做blur处理,然后再将数据投回像素空间。其核心思想分为三步: splat, blur, slice,和信号处理的频率变换很类似。
- splat: 将大规模的像素值映射(splat)到小规模的grid或lattice顶点(vertices)上,从而将数据压缩。注意这里的维度并不一定会减少,比如RGB是三维,投影到Grid上可能是五维(RGBXY),但数据量(也即是计算的数据点)却大幅减少。
- blur: 对顶点(vertices)做滤波(blur)。
- slice: 将滤波后的每个顶点再映射回像素空间中去。
Bilateral Space
这里列举几个经典关于Bilateral Space的论文及大致思想。
JiaWen Chen直接计算每个像素的灰度图,然后将灰度,像素坐标作为bilateral space的坐标基(即坐标轴),生成不同的bilateral grid(矩形网格),从而进行处理。参考文献[1]。
Andrew Adams [2][3]比较了不同的Grid/Lattice方法,认为Premutohedral Lattice的效果最好(就是四面体网络,学过有限元的应该知道,目前效果最好应用最多的就是四面体网格吧),提出了相应的映射计算方法,并采用质心插值(barycentric interpolation),相比bilinear/cublic插值,减少了计算量。这应该是目前bilateral space最好的实现了,anyway,[2]这篇论文值得一看。
Andrew Adams在他的博士论文[4]中对一些Fast Bilateral Filter进行了具体的分析和比较,还提出了采用Gaussian KD-Tree的另一种计算方法。
Simple Bilateral Grid
Premutohedral lattice虽然比较准确,但计算量还是大。Jon Barron采用Adams的思想,但用了Jiawen Chen的矩形Grid。与[2]的分析方法不同,直接将变换流程近似成了矩阵分解
其中 S 代表splat, B 代表blur, ST 代表slice。通过矩阵分解,将稠密矩阵 A 转换成两个稀疏矩阵 S 、 B 。
优化算法
待续。。。
Reference
- Chen, J., Paris, S., & Durand, F. (2007). Real-time edge-aware image processing with the bilateral grid. ACM Transactions on Graphics, 26(99), 103.
- Adams, A., Baek, J., & Davis, M. A. (2010). Fast high-dimensional filtering using the permutohedral lattice. Computer Graphics Forum, 29(2), 753–762.
- Baek, J., Adams, A., & Dolson, J. (2013). Lattice-based high-dimensional gaussian filtering and the permutohedral lattice. Journal of Mathematical Imaging and Vision, 46(2), 211–237.
- Adams, A. (2011). High-dimensional gaussian filtering for computational photography, (July), 133.