Anda di halaman 1dari 2

Fast compressive bilateral filter F Iq Cn (Iq ) = q[Vp aq Iq Cn (Iq ).

G. Deng✉ q[V aq ĝ(Ip − Iq )Iq
Ĵ p =  p
q[Vp aq ĝ(Ip − Iq )
A fast algorithm is derived for the compressive bilateral filter (CBF) by

F Iq + n=1 gn Cn (Ip )F Iq Cn (Iq ) + Sn (Ip )F Iq Sn (Iq )
representing the bilateral filter in a new way. This representation allows = N

us to use the property of the Gaussian function to reduce the number of 1 + n=1 gn Cn (Ip )F Cn (Iq ) + Sn (Ip )F Sn (Iq )
Gaussian filters required by the CBF by a factor of 2. Producing the
same results as that of the CBF, the fast algorithm runs about two The main computational steps of the CBF are listed as the following:
times faster than the CBF.
† Step 1. For the given parameters ss , sr and k, determine N.
† Step 2. Initialise the output image J = 0 and the normalisation B = 0.
Compressive bilateral filter (CBF): The bilateral filter (BF) is one of the † Step 3. For n = 1:N , do
most widely used edge-preserving filters in many applications [1]. The
1. Map each pixel of the image I to two new images Cn = cos(vn I )
BF can be written as
and Sn = sin(vn I ).
 2. Perform Gaussian filtering: Uc = F [I × Cn ] and Us = F [I × Sn ].
q[V aq g(Iq − Ip )Iq
Jp =  p (1) 3. Perform Gaussian filtering: Vc = F [Cn ] and Vs = F [Sn ].
q[Vp aq g(Iq − Ip ) 4. Perform accumulation: J = J + gn [Cn × Uc + Sn × Us ].
5. Perform accumulation: B = B + gn [Cn × Vc + Sn × Vs ].
where Ip and Jp are pixels of the input and output images at location p, † Step 4. Final output is given by: J = (F [I ] + J )/(1 + B).
respectively, Vp is the set of locations of pixels in the neighbourhood of
pixel Ip . The normalised Gaussian filter coefficient is defined as follows: In the above description, all operations are performed in a pixel-wise
aq = a exp −|p − q| 2
/2s2s (2)
 Proposed fast CBF algorithm: To develop the fast CBF algorithm, we
where a is a constant such that aq = 1. The function g(x) is a rewrite the BF(1) as the following equivalent form:
  q[Vp aq g(Iq − Ip )(Iq − Ip )
g(x) = exp −x2 /2s2r (3) Jp = Ip +  (10)
q[Vp aq g(Iq − Ip )

Due to the non-linear nature of the filter, a direct implementation of the This new representation allows us to use the derivative property of the
BF requires significant computational time. Therefore, there have been Gaussian function to develop the fast CBF algorithm. Let us define
continuous researches on developing efficient algorithms [1]. A classical 
algorithm is based on using the bilateral grid [2], while some recently h(x) = aq g(Iq − x) (11)
published algorithms are based on the idea of approximating the q[Vp
Gaussian function [3, 4]. Using the Fourier series approximation, the
CBF [3] has achieved excellent approximation to the BF with an effi- The first derivative is given by
cient implementation. In this Letter, we develop a fast algorithm for 
h′ (x) = s−2
r aq g(Iq − x)(Iq − x) (12)
the CBF making it run even faster.
Let us first revisit the main idea of the CBF. A periodic Gaussian
signal with the period 2L is defined as follows: Using the substitution x = Ip and (11) and (12), we can write (10) as
f (x + 2mL) = f (x) = g(x) (4) Jp = Ip + s2r h′ (Ip )/h(Ip ) (13)

where m is an integer and g(x) is a truncated Gaussian with g(x) = g(x) Using the Fourier series approximation (8), we can derive the following:
for |x| , L and g(x) = 0 for |x| ≥ L. Let L = ceil(k sr ) (k . 1), where 
the function ceil(x) returns the smallest integer such that ceil(x) ≥ x. The N

ĥ(Ip ) = c0 1 + gn Cn (Ip )F Cn (Iq ) + Sn (Ip )F Sn (Iq ) (14)
truncated Gaussian g(x) is a good approximation of g(x) when k ≥ 4, n=1
since g(4sr ) = 3.35 × 10−4 which is close to zero. In actual implemen-
tation, we set L = max (I) which is the maximum grey scale of the and
image. The Fourier series representation of g(x) is given by


1 ĥ′ (Ip ) = c0 gn vn Cn (Ip )F[Sn (Iq )] − Sn (Ip )F[Cn (Iq )] (15)
g(x) = c0 + 2 cn cos(vn x) (5) n=1
Substitution of (14) and (15) into (13), we have a fast implementation of
where vn = np/L for |x| ≤ L. The Fourier coefficients can be calculated the CBF algorithm described in (9) as follows:
Ĵp = Ip + s2r ĥ′ (Ip )/ĥ(Ip ) (16)
1 1   The implementation of the fast CBF follows a similar structure as that of
cn = f (x) exp(−vn x)dx = √ exp −n2 /2t2 (6)
2L −L 2p t the CBF outlined in the previous section. The major differences are in
Steps 3 and 4 which are listed below:
where vn = np/L and t = L/(psr ). Since cn is also a Gaussian with
variance t, we have cn ≈ 0 when n ≥ k t, a good approximation of † Step 3. For n = 1:N , do
g(x), denoted by ĝ(x), is obtained when 1. Map each pixel of the image I to two new images Cn = cos(vn I )
and Sn = sin(vn I ).
N = ceil(k t) = ceil(kL/(psr )). (7) 2. Perform Gaussian filtering: Vc = F [Cn ] and Vs = F [Sn ].
3. Perform accumulation: J = J + gn vn [Sn × Vc − Cn × Vs ].
Using the above approximation and defining gn = 2cn /c0 , we can write
4. Perform accumulation: B = B + gn [Cn × Vc + Sn × Vs ].
 † Step 4. Final output: J = I + s2r J /(1 + B).

g(Iq − Ip ) ≈ ĝ(Iq − Ip ) = c0 1 + gn cos vn (Iq − Ip ) (8)
n=1 For an image of M pixels and using N Gaussian filters, the main compu-
tational requirements for the CBF and the fast CBF are shown in Table 1
Substitution of (8) into (1), the CBF can be written as (9), where which shows that the fast CBF algorithm significantly reduces the com-
Cn (x) = cos (vn x), Sn (x) = sin (vn x), and the spatial Gaussian putational complexity of the CBF by reducing the number of Gaussian
filter function is denoted F. For example, we define filtering from 4N + 1 to 2N .

ELECTRONICS LETTERS 2nd February 2017 Vol. 53 No. 3 pp. 150–152

Table 1: Computational requirements for CBF and fast CBF real-time applications because the PSNR is about 43 and 54 dB,
Gaussian filters Pixel-wise multiplications
CBF 4N + 1 (8N + 1)M
0.17 62
Fast CBF 2N (6N + 1)M

running time, s

We now briefly discuss the computational cost of the fast CBF. 0.11
Referring to (7), since L is fixed for a particular image, the term N 50

depends on the parameters k and sr . While the parameter sr is set to 0.08

control the degree of smoothing, the bigger value of k results in a
0.05 42
larger value of N which in turn leads to a more accurate approximation 1 2 3 4 5 1 2 3 4 5
of the Gaussian function. This is at the cost of using more Gaussian k k

filters. Therefore, for a given set of smoothing parameter ss and sr ,

the parameter k is set to make a trade-off between computational com- Fig. 1 Effect of parameter k on trade-off between running time and
plexity and the approximation quality. In addition, for a fixed value of approximation quality
k, the fast CBF runs even faster when the range parameter sr is set to
a larger value because N is inversely proportional to sr . These properties To further study the performance of the fast CBF, we compared it to
are validated and further investigated in the following section. the bilateral grid implementation of the BF (BGBF) [2] and a recently
Since the major computational cost of the fast CBF is performing published algorithm for fast and accurate approximation of the BF
Gaussian filtering and this cost is even more profound when the par- (FABF) [4]. The source code for BGBF is available at: people.csail.
ameter ss is set to a large value, a fast Gaussian filtering algorithm is, whereas the source code for FABF is available
needed. Experimentally, we found that among many existing fast at:
Gaussian filtering algorithms [5], the algorithm based on DCT-5 [6] is bilateral-filtering. We use the test conditions (ss and sr ) suggested by
the most efficient one in terms of speed and quality. We use this the authors of their source codes. Results are presented in Table 3
Gaussian filter in our implementation of the fast CBF. which clearly shows that the proposed fast CBF is better than the
In addition, further computational savings can be achieved by not other two algorithms in terms of PSNR. When the parameter sr is set
directly calculating Cn and Sn for n . 1. We can use the following to a relatively large value, the running time of the fast CBF is faster than
calculate Cn that of the BGBF which is one of the fastest BF algorithms. This is
because for the fast CBF the number of Gaussian filters required is
Cn = C1 Cn−1 − S1 Sn−1 (17) inversely proportional to the range variance sr . Regarding the running
time, we remark that it is just an indication of the relative performance
and Sn can be calculated in a similar way. Therefore, only two multipli- of different algorithms in their provided implementations. A reliable
cations are needed to calculate the cosine/sine of a pixel. indicator is the number of operations such as those shown in Table 1.
Experimental validation and comparison: All our experiments were
conducted in MATLAB which is run in a computer with an Intel i7 pro- Table 3: Comparison of the performance of the fast CBF (k = 2)
cessor and 12 GB RAM. Due to space limitation, we only report results with those of the BGBF and FABF (eps = 10−3 )
using the ‘peppers’ image which is a test image in MATLAB (‘peppers. ss = 24.7, sr = 24
png’). We observed similar and consistent results using other images. In ss = 3, sr = 40 [4]
our experiment, the running time is used as an indication of the speed, Time (s) PSNR (dB) Time (s) PSNR (dB)
while the PNSR with respect to the brute-force implementation of the BGBF [2] 0.0656 49.15 0.0388 43.27
bilateral filter is used as a measure of the quality of approximation. Fast CBF 0.0396 55.80 0.0627 51.83
We first present the validation of the proposed fast CBF algorithm. FABF [4] 0.2156 45.14 2.7222 41.07
The source code of the CBF is available at:
compressive-bilateral-filter. Results are shown in Table 2 which shows Conclusion: In this Letter, we have presented a fast algorithm for the
that the fast CBF produces the same result as that of the CBF at about CBF. At about twice the speed of the CBF, the fast algorithm produces
twice the speed. This is an expected result as the number of required exactly the same result. We have demonstrated that the parameter of the
Gaussian filters is reduced by a factor of 2. fast CBF can be set to achieve a trade-off between running speed and
approximation accuracy. We have also demonstrated that the perform-
Table 2: Validation of the fast CBF with (A) sr = 20, ss varying ance of the proposed fast CBF is competitive to the classical bilateral
from 5 to 20, and (B) ss = 20, sr varying from 5 to 20 grid algorithm and a recently published approximation-based algorithm.
CBF (tol = 10−4 ) fast CBF (k = 3)
Time (s) PSNR (dB) Time (s) PSNR (dB) © The Institution of Engineering and Technology 2017
(A) Submitted: 19 September 2016 E-first: 9 January 2017
5 0.1957 65.93 0.0978 65.92 doi: 10.1049/el.2016.3416
10 0.1970 61.41 0.0970 61.36 One or more of the Figures in this Letter are available in colour online.
15 0.1955 58.68 0.0988 58.63
G. Deng (Department of Engineering, La Trobe University, Bundoora,
20 0.1996 57.46 0.1012 57.44 Victoria 3086, Australia)
✉ E-mail:
CBF (tol = 10−4 ) fast CBF (k = 3)
Time (s) PSNR (dB) Time (s) PSNR (dB)
5 0.1948 61.41 0.0977 61.36 1 Paris, S., Kornprobst, P., Tumblin, J., and Durand, F.: ‘Bilateral filtering:
theory and applications’, Found. Trends Comput. Graph. Vis., 2008, 4,
10 0.1536 59.12 0.0719 59.12
pp. 1–73
15 0.1248 57.67 0.0531 57.68 2 Paris, S., and Durand, F.: ‘A fast approximation of the bilateral filter using
20 0.1073 56.60 0.0455 56.63 a signal processing approach’, Int. J. Comput. Vis., 2009, 81, pp. 24–53
3 Sugimoto, S., and Kamata, S.: ‘Compressive bilateral filtering’, IEEE
Trans. Image Process., 2015, 24, pp. 3357–3369
Next, we study the effect of the parameter k on the trade-off between 4 Chaudhury, K., and Dabhade, S.: ‘Fast and provably accurate bilateral
running time and approximation quality. We fixed sr = 20, ss = 10 and filtering’, IEEE Trans. Image Process., 2016, 25, pp. 2519–2528
set k from 1.5 to 5 with an increasing step of 0.5. Fig. 1 clearly shows 5 Getreuer, P.: ‘A survey of Gaussian convolution algorithms’, Image
Process. Line, 2015, 3, pp. 286–310
that (i) the running time is linearly increasing with k, (ii) the setting
6 Sugimoto, S., and Kamata, S.: ‘Efficient constant-time Gaussian filtering
k = 3 has achieved the best peak signal to noise ratio (PSNR) results with sliding DCT/DST-5 and dual-domain error minimization’, ITE
because setting k . 3 does not lead to noticeable improvement in Trans. Media Technol. Appl., 2015, 3, pp. 12–21
PSNR, and (iii) setting k = 1.5 or k = 2 would be sufficient for some

ELECTRONICS LETTERS 2nd February 2017 Vol. 53 No. 3 pp. 150–152