components.arithmetic
Do simple arithmetic. |
|
Do simple arithmetic with two inputs. |
- class Arithmetic(config={}, **kwds)[source]
Bases:
Transformer
Do simple arithmetic.
Applies a user supplied arithmetical expression to every pixel in each frame. To set the expression, set the component’s
func
config 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..235
to64..204
you 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_float
to coerce numbers to the Pyctools default floating point type (numpy:numpy.float32
). NumPy will otherwise convert Pythonfloat
tonumpy:numpy.float64
.
- class Arithmetic2(config={}, **kwds)[source]
Bases:
Component
Do 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.