components.arithmetic
Do simple arithmetic. |
|
Do simple arithmetic with two inputs. |
- class Arithmetic(config={}, **kwds)[source]
Bases:
TransformerDo simple arithmetic.
Applies a user supplied arithmetical expression to every pixel in each frame. To set the expression, set the component’s
funcconfig to a suitable string expression. The input data should appear in your expression as the worddata.For example, to convert video levels from the range
16..235to64..204you could do this:setlevel = Arithmetic( func='((data - pt_float(16.0)) * pt_float(140.0 / 219.0)) + pt_float(64.0)') ... pipeline(..., setlevel, ...)
Note the liberal use of
pt_floatto coerce numbers to the Pyctools default floating point type (numpy:numpy.float32). NumPy will otherwise convert Pythonfloattonumpy:numpy.float64.
- class Arithmetic2(config={}, **kwds)[source]
Bases:
ComponentDo simple arithmetic with two inputs.
Similar to
Arithmetic, but has two inputs. For example, to subtract the second input from the first you could do:subtracter = Arithmetic2(func='data1 - data2')
- inputs = ['input1', 'input2']
Comments or questions? Please email jim@jim-easterbrook.me.uk.