Graphics Reference
In-Depth Information
As seen in Equation (10.2) (Paris), the bilateral filter weights are a product of a
Gaussian function based on the spatial distance (indicated by G s ), and a Gaussian function
based on the color delta value (indicated by G r ). This dependence on the intensity values
is the key to performing a filtering operation that preserves edges in the image. However,
since every pixel in the image has a potentially different value, the weights must be calcu-
lated dynamically for every sample that is used to produce an output pixel value. This is
a relatively large difference from the Gaussian filter, where we could easily precalculate
the desired filter weight based on the desired sigma value. In addition, since the weights
change from pixel to pixel, the bilateral filter is a nonlinear filter, which also means that
it is generally not separable. This can have profound performance implications when suf-
ficiently large filter sizes are used.
Once all of the weights have been calculated,
the resulting output pixel value is determined in
the same way as in as the Gaussian filter. The
appropriate neighboring pixels are sampled, and
then scaled by the current pixel's corresponding
weighting value. All of these weighted samples
are then summed to produce an output pixel value.
Another very important point to consider when
calculating the bilateral filter weights is that the
content of the image may produce filter weights
that add up to significantly less than 1. This can
produce an abnormally darkened area in an area that is otherwise relatively bright, which
would appear out of place. This is in contrast to Gaussian filter weights, which are chosen
to always add up to a total of 1. To compensate for this fluctuation in total weight, the total
contributions from all of the pixels must be renormalized with one another. This is done
by trivially dividing the resulting pixel value by the sum of the weights themselves. This is
depicted graphically in Figure 10.12.
Another complication to using this filter is the fact that there are three independent
channels in a normal color texture. This means that the intensity parameter that is used
for the Gaussian filter weighting must either be performed for all three channels indepen-
dently, or some mechanism must be used to convert from a three-dimensional color to a
one-dimensional equivalent value prior to calculating the weight values. Both possibilities
will increase the number of calculations needed to determine the weight values, and the
latter option will reduce the image quality of the filter somewhat, by approximating the
color space with a single scalar value. In principle, since the GPU is capable of perform-
ing vector style calculations, it should be possible to calculate each of the color channels
independently with the same number of instructions. 2
Figure 10.12. Renormalizing of the bilat-
eral filter weights.
2 In the past, all GPU architectures were vector-register based. However, this is not the case any longer, with
recent NVIDIA architectures using a scalar execution pipeline (while recent AMD architectures remain vector
based). Thus, the comments presented here about vector operations may or may not apply to a particular GPU.
Search WWH ::




Custom Search