1. Field of the Invention
The present invention generally relates to a bilateral filter, and more particularly to fast bilateral filtering using a bilateral histogram.
2. Description of Related Art
A bilateral filter is a nonlinear edge preserving filter that smooths an image while preserving edges. The intensity value at each pixel in the image is replaced by a weighted average of intensity values from nearby pixels. It has demonstrated great effectiveness for many computer vision and computer graphics problems such as tone mapping, demosaicking and low-light enhancement.
The bilateral filer is a nonlinear combination of spatial and range filters. Implementing the bilateral filter is computationally intensive owing to the nonlinearity of the range filter. Conventional techniques are proposed to speed up bilateral filtering either by confining the spatial kernel or numerical approximation. The memory cost for the conventional bilateral filtering can be unacceptable large for small kernel size.
A need has thus arisen to propose a novel scheme to overcome drawbacks of the conventional bilateral filters.
In view of the foregoing, it is an object of the embodiment of the present invention to provide fast bilateral filtering using a bilateral histogram, which is a balanced choice of bilateral filter in terms of efficiency, kernel generality and memory size.
According to one embodiment, an image patch is decomposed by pixel intensity to form a stack of patches, and spatial filtering response of each intensity is computed. The spatial filtering response of each intensity is multiplied by corresponding intensity, thereby resulting in multiplied spatial filtering response of each intensity. The multiplied spatial filtering responses of different intensities weighted with corresponding range weights are then summed up.
According to another embodiment, an image patch is decomposed by pixel intensity to form a stack of patches. A vertical spatial filtering response of each intensity is computed, and a horizontal spatial filtering response of each intensity is computed. A product of the horizontal spatial filtering response and the vertical spatial filtering response is multiplied by corresponding intensity, thereby resulting in a multiplied spatial filtering response. The multiplied spatial filtering responses of different intensity levels weighted with corresponding range weights are then summed up.
The form of a bilateral filter is a nonlinear combination of spatial filters and range filters:
where IB(p) denotes a filtering output of pixel p, q denotes a neighbor pixel of p in a local region N(p), Gs(p,q) and Gr(I(p),I(q)) denote a spatial kernel function and a range kernel function, respectively. In one example, the spatial kernel function and the range kernel function may be Gaussian function. W is a normalization factor and may be represented as
The bilateral filter in Eq. (1) can be viewed as per pixel division of two sets of filter response, that is, J(p)/W(p). The numerator J(p) may be represented and be rearranged as follows:
where i denotes an intensity value, e.g., iε[0, 255] for 8-bit grayscale image, and δ(·) is an indicator function
Eq. (3) can be further rearranged to
The denominator W(p) has the similar form:
At step 11, an (original) image patch is decomposed by pixel intensity to form a stack of patches δ(i,I(q)) of intensity i by a decompose unit 111. The stack of patches may be stored in a memory 110.
At step 12, a spatial filtering response
of intensity i is computed by a spatial filter 112. At step 13, the spatial filtering response of intensity i is multiplied by the corresponding intensity i, thereby resulting in multiplied spatial filtering response. The step 13 may be carried out by a multiplier 113. Finally, at step 14, the multiplied spatial filtering responses of different intensity levels weighted with corresponding range weights Gr(I(P), i) are summed up, by a summation unit 114, to result in the numerator J(p) of Eq. (5).
It is noted that the computation of J(p) and W(p) shares the same spatial filtering response of intensity patches. The only difference is that there is no need to perform step 13 when computing W(p).
According to the embodiment shown in
For filtering a 8-bit grayscale image with radius r, we need 256×(2r+1)×(2r+1) buffer size. It is noted that the storage is a 3D table. As the stack structure is usually sparse since every pixel position only contributes to one intensity layer, a bilateral filtering method using bilateral histogram (or 2D table) is proposed according a second embodiment of the present invention.
First, a 2D spatial filtering may be decomposed into two pass 1D spatial filtering:
where Gsh(·) denotes a horizontal spatial filter and Gsv(·) denotes a vertical spatial filter. Usually, the spatial filter kernel is isotropic and thus Gsh(·) and Gsv(·) are the same function, e.g., 2D Gaussian filtering as two-pass 1D Gaussian filtering. In a scanline order, vertical filter is performed first. Accordingly, the numerator J(p) may be represented as follows:
of intensity i is computed by a vertical spatial filter 132. At step 33, a horizontal spatial filtering response
of intensity i is computed by a horizontal spatial filter 133.
At step 34, the product of the horizontal spatial filtering response and the vertical spatial filtering response is multiplied by the corresponding intensity i, thereby resulting in a multiplied spatial filtering response. The product may be generated by a first multiplier 134A, and the multiplied spatial filtering response may be generated by a second multiplier 134B. Finally, at step 35, the multiplied spatial filtering responses of different intensity levels weighted with corresponding range weights Gr(I(P), i) are summed up, by a summation unit 135, to result in the numerator J(p) of Eq. (8).
Like the first embodiment, it is noted that the computation of J(p) and W(p) shares the same spatial filtering response of intensity patches. The only difference is that there is no need to perform step 34 when computing W(p).
In the embodiment, data storage required to compute the bilateral filter response becomes a 2D table with a buffer size of 256×(2r+1) for a 8-bit grayscale image with filter radius r. One dimension of the 2D table is for intensity and the other dimension is for the vertical spatial filtering response of different horizontal positions. The 2D table is also called bilateral histogram. According to the embodiment, step 32 may thus be performed by shifting the bilateral histogram and updating the vertical spatial filtering responses of each intensity.
The bilateral histogram described above may reduce the storage compared to the first embodiment. However, it still happens with high probability that more than half of the entries in the histogram are empty in our quantitative evaluation. Therefore, a modified first-in-first-out (FIFO) data structure is proposed to optimize the present embodiment.
Although specific embodiments have been illustrated and described, it will be appreciated by those skilled in the art that various modifications may be made without departing from the scope of the present invention, which is intended to be limited solely by the appended claims.
| Number | Name | Date | Kind |
|---|---|---|---|
| 8315473 | Tao | Nov 2012 | B1 |
| 20110050934 | Mitsunaga | Mar 2011 | A1 |
| 20110200269 | Das Gupta | Aug 2011 | A1 |
| 20120200669 | Lai | Aug 2012 | A1 |
| Entry |
|---|
| Rashi Agarwal “Bit plane average filtering to remove Gaussian noise from high contrast images” IEEE 2012. |
| Number | Date | Country | |
|---|---|---|---|
| 20170011497 A1 | Jan 2017 | US |