Abstract
Many computer vision and human-computer interaction applications developed in recent years need evaluating complex and continuous mathematical functions as an essential step toward proper operation. However, rigorous evaluation of these kind of functions often implies a very high computational cost, unacceptable in real-time applications. To alleviate this problem, functions are commonly approximated by simpler piecewise-polynomial representations. Following this idea, we propose a novel, efficient, and practical technique to evaluate complex and continuous functions using a nearly optimal design of two types of piecewise linear approximations in the case of a large budget of evaluation subintervals. To this end, we develop a thorough error analysis that yields asymptotically tight bounds to accurately quantify the approximation performance of both representations. It provides an improvement upon previous error estimates and allows the user to control the tradeoff between the approximation error and the number of evaluation subintervals. To guarantee real-time operation, the method is suitable for, but not limited to, an efficient implementation in modern graphics processing units, where it outperforms previous alternative approaches by exploiting the fixed-function interpolation routines present in their texture units. The proposed technique is a perfect match for any application requiring the evaluation of continuous functions; we have measured in detail its quality and efficiency on several functions, and, in particular, the Gaussian function because it is extensively used in many areas of computer vision and cybernetics, and it is expensive to evaluate.
Introduction
In fields like computer vision and human-computer interaction, algorithms often need to evaluate complex functions billions of times per second. For example, high-quality background subtraction—the process of separating moving objects from a static scene—often relies on "nonparametric" models that require calculating massive numbers of Gaussian kernels. The "exact" mathematical functions provided by standard programming libraries (like exp() in C++) are computationally expensive and can become a bottleneck for real-time performance. While developers often turn to simpler approximations, these often lack rigorous error bounds or fail to take full advantage of the parallel processing power and specialized hardware features of modern Graphics Processing Units (GPUs).
Mathematical Optimization and Methods
The proposed technique replaces complex continuous functions with Continuous Piecewise Linear (CPWL) approximations. The approach is two-pronged, focusing on both mathematical optimization and hardware-specific acceleration. The authors analyze two primary types of approximations: linear interpolation and orthogonal projection.
By utilizing a principle called "error equalization," the method designs a suboptimal partition of the function's domain. This involves placing more "knots" (data points) in regions where the function curves sharply and fewer where it is nearly flat. A significant theoretical finding is that using an orthogonal projection instead of simple linear interpolation can achieve a $\sqrt{6}$ factor improvement in accuracy for the same number of segments.
Hardware Acceleration via Texture Units
To achieve maximum speed, the method exploits the dedicated Texture Units found in modern GPUs. Originally designed to smooth out images in games, these units have fixed-function hardware specifically for linear interpolation. By storing function samples in a texture, the GPU can perform the interpolation math almost for free. This approach avoids "branch divergence"—a common issue where different threads take different amounts of time to process—which typically slows down complex mathematical kernels on GPUs. Using the texture unit proved faster than using the GPU's own Special Function Units (SFUs).
Key Results and Performance
The performance of the proposed method was evaluated using mathematical functions like the Gaussian, Lorentzian, and Bessel functions, as well as real-world video sequences for foreground segmentation.
Key findings include:
- Speed: On an NVIDIA GTX 580, the uniform partition method was 4x faster than the standard C library
expfand 2x faster than the hardware-accelerated SFU__expf. - Accuracy: The error follows an $O(N^{-2})$ convergence rate, meaning that doubling the number of segments roughly quadruples the accuracy. The provided error analysis yields asymptotically tight bounds that accurately quantify performance.
- Application Impact: In a nonparametric background modeling application, the method outperformed exact Gaussian implementation by 27% in total processing time while maintaining identical segmentation results.
Conclusion
While non-uniform partitions are mathematically superior, they currently face overhead costs due to the binary search required to find the correct subinterval on current GPU architectures. However, for many real-time tasks, a uniform partition leveraging texture hardware represents the practical "sweet spot" for speed and precision. As GPU architectures evolve, these optimized partitions could become a new standard for high-precision scientific computing and real-time cybernetics.
Summary updated