cutcutcodec.core.generation.video.equation.GeneratorVideoEquation
- class cutcutcodec.core.generation.video.equation.GeneratorVideoEquation(*colors: Basic | Real | str)[source]
Generate a video stream whose channels are defened by any equations.
It is a particular case of
cutcutcodec.core.filter.equation.FilterVideoEquation.Examples
>>> from cutcutcodec.core.generation.video.equation import GeneratorVideoEquation >>> (stream,) = GeneratorVideoEquation( ... "atan(pi*j)/pi + 1/2", # dark blue on the left and bright on the right ... "sin(2pi(i-t))**2", # horizontal descending green waves ... "exp(-(i**2+j**2)/(2*(1e-3+.1*t)))", # red spot in the center that grows ... ).out_streams >>> stream.node.colors [atan(pi*j)/pi + 1/2, sin(2*pi*(i - t))**2, exp((-i**2 - j**2)/((2*(0.1*t + 0.001))))] >>> stream.snapshot(0, (13, 9))[..., 0] # blue at t=0 tensor([[ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230], [ 25, 33, 46, 73, 128, 182, 209, 222, 230]], dtype=torch.uint8) >>> stream.snapshot(0, (13, 9))[..., 1] # green at t=0 tensor([[ 0, 0, 0, 0, 0, 0, 0, 0, 0], [191, 191, 191, 191, 191, 191, 191, 191, 191], [191, 191, 191, 191, 191, 191, 191, 191, 191], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [191, 191, 191, 191, 191, 191, 191, 191, 191], [191, 191, 191, 191, 191, 191, 191, 191, 191], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [191, 191, 191, 191, 191, 191, 191, 191, 191], [191, 191, 191, 191, 191, 191, 191, 191, 191], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [191, 191, 191, 191, 191, 191, 191, 191, 191], [191, 191, 191, 191, 191, 191, 191, 191, 191], [ 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=torch.uint8) >>> stream.snapshot(0, (13, 9))[..., 2] # red at t=0 tensor([[ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 255, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=torch.uint8) >>> stream.snapshot(1, (13, 9))[..., 2] # red at t=1 tensor([[ 0, 0, 1, 1, 2, 1, 1, 0, 0], [ 0, 1, 2, 6, 8, 6, 2, 1, 0], [ 0, 2, 8, 21, 28, 21, 8, 2, 0], [ 1, 5, 21, 54, 74, 54, 21, 5, 1], [ 1, 9, 43, 108, 147, 108, 43, 9, 1], [ 2, 14, 64, 163, 222, 163, 64, 14, 2], [ 2, 16, 74, 187, 255, 187, 74, 16, 2], [ 2, 14, 64, 163, 222, 163, 64, 14, 2], [ 1, 9, 43, 108, 147, 108, 43, 9, 1], [ 1, 5, 21, 54, 74, 54, 21, 5, 1], [ 0, 2, 8, 21, 28, 21, 8, 2, 0], [ 0, 1, 2, 6, 8, 6, 2, 1, 0], [ 0, 0, 1, 1, 2, 1, 1, 0, 0]], dtype=torch.uint8) >>>
Initialise and create the class.
Parameters
- *colorsstr or sympy.Basic
Transmitted to the
cutcutcodec.core.filter.video.equation.FilterVideoEquationinitialisator. But the only available vars are t, i and j.