Interpolater
Interpolate tracks based on propagation module.
- class byotrack.implementation.refiner.interpolater.ForwardBackwardInterpolater(method: str | DirectedPropagate = 'constant', full=False, **kwargs)
Bases:
RefinerInterpolate tracks to fill out NaN values by averaging a forward estimation and a backward estimation.
We propose three modes for position propagation: constant, tps and flow. Constant estimation propagates the last known position, tps interpolates elastically the motion of the active tracks to fill missing ones and flow uses optical flow to propagate the tracks.
Forward and backward propagation are smoothly merged together in a weighted average. See propagation module
- method
Method to use for position propagation. Either “constant”, “tps” or “flow” (see constant_directed_propagate, tps_directed_propagate or optical_flow_directed_propagate) or a user defined Callable following the DirectedPropagate protocol. The method will be called with the tracks_matrix, video, a boolean direction and additional kwargs.
- Type:
- full
If True, it will extrapolate positions for all the frames of the video If False, it will only interpolate NaN values inside each track domain, without extrapolation Default: False
- Type:
- kwargs
Additional parameters given to method. For instance for “tps”, you can set alpha (float) which is the regularization parameter of the interpolation (see tps_propation module and torch_tps librarie). We advise to use alpha > 5.0 (alpha = 10 by default). For “flow” propagation, you should provide optflow (byotrack.OpticalFlow) to correctly estimate optical flows.
- Type:
Dict[str, Any]
- run(video: Iterable[ndarray], tracks: Collection[Track]) List[Track]
Run the refiner on a whole video
- Parameters:
video (Iterable[np.ndarray]) – Sequence of frames (video) Each array is expected to have a shape (H, W, C)
tracks (Collection[byotrack.Track]) – Tracks of particles
- Returns:
Refined tracks of particles
- Return type:
Collection[byotrack.Track]