Graphics Reference
In-Depth Information
This implementation is perfectly adequate
for producing a blurred output image in the math-
ematically correct way. With the highly parallel
nature of modern GPUs, this operation is likely
to be performed quite quickly. However, there
is almost always a need to perform more opera-
tions in every rendered frame, to allow either for
better image quality or for higher throughput of
an operation if it used in a GPGPU application.
Therefore, we will attempt to improve the perfor-
mance of our algorithm, while still producing the
same output image.
Figure 10.7. A visualization of applying the
filter kernel to a single pixel.
Separable Gaussian Filter
In our brief image processing primer, we saw that some filter kernels are separable. The
Gaussian filter is in fact a separable filter, which we can exploit to gain a significant per-
formance advantage. When a 2D filter is decomposed into two ID filters, this requires us
to execute two processing passes on our image —one for each of the two ID filters. In the
case of the Gaussian filter, both of the ID filters are simply the cross section of the 2D filter
through its center. In the 7×7 filter from our example above, the decomposition into two
ID filters will produce a 1×7 filter and a 7×1 filter. This can be thought of as producing
filters in both the x- and y -directions, due to the shape of the resulting filters. This is shown
graphically in Figure 10.8.
The first processing pass will read the input image, apply the first filter, and produce
an intermediate image result which must be stored in a new texture resource. The sec-
ond processing pass will read the intermediate result, apply the second filter, and produce
the final filtered image. This means that we will require an additional texture resource,
which means that additional memory is used by this modified algorithm. However, the
potential performance improvement is typically a worthy tradeoff for the extra memory
consumption.
Figure 10.8. Decomposing our 7×7 filter into two ID filters.
Search WWH ::




Custom Search