Bilateral filter

A bilateral filter is a non-linear, edge-preserving, and noise-reducing smoothing filter for images.

This weight can be based on a Gaussian distribution. Crucially, the weights depend not only on Euclidean distance of pixels, but also on the radiometric differences.

bf(I)p=1WpqN(p)Gσs(pq)Gσr(IpIq)IqWp=qN(p)Gσs(pq)Gσr(IpIq)\begin{aligned} b f(I)_{\mathbf{p}} &=\frac{1}{W_{\mathbf{p}}} \sum_{\mathbf{q} \in N(\mathbf{p})} G_{\sigma_{\mathrm{s}}}(\|\mathbf{p}-\mathbf{q}\|) G_{\sigma_{\mathrm{r}}}\left(\left|I_{\mathbf{p}}-I_{\mathbf{q}}\right|\right) I_{\mathbf{q}} \\ W_{\mathbf{p}} &=\sum_{\mathbf{q} \in N(\mathbf{p})} G_{\sigma_{\mathrm{s}}}(\|\mathbf{p}-\mathbf{q}\|) G_{\sigma_{\mathrm{r}}}\left(\left|I_{\mathbf{p}}-I_{\mathbf{q}}\right|\right) \end{aligned}

  • 空间距离:当前点与中心点的欧式距离

    e(xixC)2+(yiyC)22σ2\mathrm{e}^{-\frac{\left(x_{i}-x_{C}\right)^{2}+\left(y_{i}-y_{C}\right)^{2}}{2 \sigma^{2}}}

  • 灰度距离:指的是当前点的灰度与中心点灰度的差的绝对值

    e(gray(xi,yi)gray(xc,yc))22σ2\mathrm{e}^{-\frac{\left(\operatorname{gray}\left(x_{i}, y_{i}\right)-\operatorname{gray}\left(x_{c}, y_{c}\right)\right)^{2}}{2 \sigma^{2}}}

2. Bilateral Grid

image-20220221180058090

2.1 edge-aware brush

image-20220221181057600

2.2 Defination

Data Structure

3d array:

  • the first 2 dimensions (x, y) correspond to 2D position in the image plane and form the spatial domain
  • the third dimension z corresponds to a reference range, typically is image intensity

Samping

  • SsS_s: the sampling rate of spatial axes
  • SrS_r: the sampling rate of the range axis.

The number of grid cells is inversely proportional to the sampling rate: a smaller sampling rate yields a larger number of grid cells

2.3 Basic Usage of a Bilateral Grid

Grid Creation

image-20220221182523800

image-20220221182600396

Slicing

Slicing is the critical bilateral grid operation that yields a piecewise-smooth output.

Given a bilateral grid Γ\Gamma and a reference image E, we extract a 2D value map M by accessing the grid at (x/Ss,y/Ss,E(x,y)/sr)(x/S_s, y/S_s, E(x,y)/s_r)

image-20220221183428699

  • 上图d就是在process之后取回滤波后的值
    • 比如之前有一个像素的位置是(x,y,p)(x,y,p),然后就去相应的位置取采样后的值
    • 由图©可以看出图像已经平滑过了,而强度相差较大的点因为在三维空间上不连续所以不受影响。