Scikit-Image

class byotrack.implementation.optical_flow.skimage.SkimageOpticalFlow(method: Callable[..., np.ndarray], downscale: float | np.ndarray = 2, blur: None | float | np.ndarray = None, parameters: dict[str, Any] | None = None)

Bases: OpticalFlow

Wraps Scikit-Image optical flow implementations.

It supports 3D optical flow and can work with any function matching Scikit-Image pattern.

Usage:

import skimage.registration  # Requires to install scikit image
from byotrack.implementation.optical_flow.skimage import SkimageOpticalFlow

# See the documentation of Scikit-Image for each algorithm to correctly set the parameters
parameters = {}

# ILK
optflow = SkimageOpticalFlow(skimage.registration.optical_flow_ilk, parameters=parameters)

# TVL1
optflow = SkimageOpticalFlow(skimage.registration.optical_flow_tvl1, parameters=parameters)
method

The optical flow function from skimage. In skimage, only two currently exists: skimage.registration.optical_flow_ilk or skimage.registration.optical_flow_tvl1.

Type:

Callable[Any, np.ndarray]

parameters

Parameters that are given to method as known arguments.

Type:

dict[str, Any]

compute(reference: ndarray, moving: ndarray) ndarray

Compute the optical flow map from reference to the moving frame.

It computes the displacement of each pixel from the reference frame to be in the moving one.

Parameters:
  • reference (np.ndarray) – Reference frame Shape: ([D’, ]H’, W’, C), dtype: float

  • moving (np.ndarray) – Moving frame Shape: ([D’, ]H’, W’, C), dtype: float

Returns:

Optical flow map from reference to moving

The flow field is stored in pixel coordinates ([dk’, ]di’, dj’) (!= xyz) Shape: (dim, [D’, ]H’, W’), dtype: float32

Return type:

np.ndarray