labels_to_flows#

cellpose_omni.dynamics.labels_to_flows(labels, files=None, use_gpu=False, device=None, redo_flows=False, links=None, dim=2)[source]#

convert labels (list of masks or flows) to flows for training model

if files is not None, flows are saved to files to be reused

Parameters

labels (list of ND-arrays) -- labels[k] can be 2D or 3D, if [3 x Ly x Lx] then it is assumed that flows were precomputed. Otherwise labels[k][0] or labels[k] (if 2D) is used to create flows and cell probabilities.

Returns

flows -- flows[k][0] is labels[k], flows[k][1] is cell distance transform, flows[k][2] is Y flow, flows[k][3] is X flow, and flows[k][4] is heat distribution

Return type

list of [4 x Ly x Lx] arrays