cutcutcodec.core.filter.video.equation

Allow to filter independentely each audio and video samples by any equation.

Classes

FilterVideoEquation(in_streams, *colors)

Apply any equation on each pixels.

Details

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, [[[0.497607  , 0.39478773, 0.9274047 ],
                [0.15067011, 0.22403193, 0.99580735]],

               [[0.72088575, 0.3723899 , 0.49151766],
                [0.92104626, 0.01184928, 0.81375337]]])
>>> stream_out.snapshot(0, (2, 2))
FrameVideo(0, [[[0.497607  , 0.6065998 , 0.        ],
                [0.15067011, 0.45683646, 0.        ]],

               [[0.72088575, 0.52826446, 0.        ],
                [0.92104626, 0.5822163 , 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 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).