March 2020
Intermediate to advanced
366 pages
9h 8m
English
Curve filters are computationally expensive because the values of f(x) must be interpolated whenever x does not coincide with one of the prespecified anchor points. Performing this computation for every pixel of every image frame that we encounter would have dramatic effects on performance.
Instead, we make use of a lookup table. Since there are only 256 possible pixel values for our purposes, we need to calculate f(x) only for all the 256 possible values of x. Interpolation is handled by the UnivariateSpline function of the scipy.interpolate module, as shown in the following code snippet:
from scipy.interpolate import UnivariateSpline def spline_to_lookup_table(spline_breaks: list, break_values: ...