cutcutcodec.core.filter.video.equation.FilterVideoEquation

class cutcutcodec.core.filter.video.equation.FilterVideoEquation(in_streams: Iterable[StreamVideo], *colors: Basic | Real | str)[source]

Apply any equation on each pixels.

The relation is only between the pixel at the same timestamp at the same position.

Attributes

colorslist[sympy.core.expr.Expr]

The luminosity expression of the differents channels (readonly).

Examples

>>> from cutcutcodec.core.filter.video.equation import FilterVideoEquation
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
>>> (stream_in,) = GeneratorVideoNoise(0).out_streams
>>> (stream_out,) = FilterVideoEquation([stream_in], "b0", "(b0+g0+r0)/3", "0").out_streams
>>> stream_in.snapshot(0, (2, 2))
FrameVideo(0, [[[127, 101, 236],
                [ 38,  57, 254]],

               [[184,  95, 125],
                [235,   3, 208]]])
>>> stream_out.snapshot(0, (2, 2))
FrameVideo(0, [[[127, 155,   0],
                [ 38, 116,   0]],

               [[184, 135,   0],
                [235, 148,   0]]])
>>>

Initialise and create the class.

Parameters

in_streamstyping.Iterable[Stream]

Transmitted to cutcutcodec.core.classes.filter.Filter.

*colorsstr or sympy.Basic

The brightness of the color channels. The channels are interpreted like is describe in cutcutcodec.core.classes.frame_video.FrameVideo. The return values will be cliped to stay in the range [0, 1]. The value is 0 for min brightness and 1 for the max. If the expression gives a complex, the module is taken. The variables that can be used in these functions are the following:

  • iThe relative position along the vertical axis (numpy convention).

    This value evolves between -1 and 1.

  • jThe relative position along the horizontal axis (numpy convention).

    This value evolves between -1 and 1.

  • t : The time in seconds since the beginning of the video.

  • bi: The blue channel of the stream index i, i starts from 0 included.

    This value evolves between 0 (dark) and 1 (light).

  • gi: The green channel of the stream index i, i starts from 0 included.

    This value evolves between 0 (dark) and 1 (light).

  • ri: The red channel of the stream index i, i starts from 0 included.

    This value evolves between 0 (dark) and 1 (light).

  • ai: The alpha channel of the stream index i, i starts from 0 included.

    This value evolves between 0 (transparent) and 1 (blind).

property colors: list[Basic]

Return the luminosity expression of the differents channels.

classmethod default()[source]

Provide a minimalist example of an instance of this node.

property free_symbols: set[Symbol]

Return the set of the diferents used symbols.