flowpy_torch.py
This code is a port to PyTorch of the flow to RGB convertion from flowpy.
https://gitlab-research.centralesupelec.fr/2018seznecm/flowpy
- ptlflow.utils.flowpy_torch.flow_to_rgb(flow: Tensor, flow_max_radius: float | Tensor | None = None, background: str = 'bright', custom_colorwheel: Tensor | None = None) Tensor [source]
Create a RGB representation of an optical flow.
- Parameters:
- flowtorch.Tensor
Flow with at least 3 dimensions in the …CHW (…, Channels, Height, Width) layout, where … represents any number of dimensions. flow[…, 0, h, w] should be the x-displacement flow[…, 1, h, w] should be the y-displacement
- flow_max_radiusfloat or torch.Tensor, optional
Set the radius that gives the maximum color intensity, useful for comparing different flows. Default: The normalization is based on the input flow maximum radius per batch element.
- backgroundstr, default ‘bright’
States if zero-valued flow should look ‘bright’ or ‘dark’.
- custom_colorwheeltorch.Tensor
Use a custom colorwheel for specific hue transition lengths. By default, the default transition lengths are used.
- Returns:
- torch.Tensor
The RGB representation of the flow. RGB values are float in the [0, 1] interval. The output shape is (…, 3, H, W).
- Raises:
- ValueError
If the background choice is invalid.
See also
ptlflow.utils.external.flowpy.make_colorwheel
How the colorwheel can be generated.