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
>>> import torch >>> 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], "r0", "(r0+g0+b0)/3", 0).out_streams >>> torch.round(stream_in.snapshot(0, (2, 2)), decimals=4) FrameVideo(0, [[[0.4976, 0.3948, 0.9274], [0.1507, 0.224 , 0.9958]], [[0.7209, 0.3724, 0.4915], [0.921 , 0.0118, 0.8138]]]) >>> torch.round(stream_out.snapshot(0, (2, 2)), decimals=4) FrameVideo(0, [[[0.4976, 0.6066, 0. ], [0.1507, 0.4568, 0. ]], [[0.7209, 0.5283, 0. ], [0.921 , 0.5822, 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.
- ri: The red 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).
- bi: The blue 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).