Downsample#

class tonic.transforms.Downsample(time_factor: float = 1, spatial_factor: Union[float, Tuple[float, float]] = 1, sensor_size: Optional[Tuple[int, int, int]] = None, target_size: Optional[Tuple[int, int]] = None)[source]#

Multiplies timestamps and spatial pixel coordinates with separate factors. Useful when the native temporal and/or spatial resolution of the original sensor is too high for downstream processing, notably when converting to dense representations of some sort. This transform does not drop any events.

Parameters:
  • time_factor (float) – value to multiply timestamps with. Default is 1.

  • spatial_factor (float or tuple of floats) – values to multiply pixel coordinates with. Default is 1. Note that when using subsequential transforms that require sensor_size, you must change the spatial values for the later transformation.

  • sensor_size (tuple) – size of the sensor that was used [W,H,P]

  • target_size (tuple) – size of the desired resolution [W,H]

Example

>>> from tonic.transforms import Downsample
>>> transform1 = Downsample(time_factor=0.001) # change us to ms
>>> transform2 = Downsample(spatial_factor=0.25) # reduce focal plane to 1/4.
>>> transform3 = Downsample(sensor_size=(40, 20, 2), target_size=(10, 5)) # reduce focal plane to 1/4.