masks_to_flows#

cellpose_omni.dynamics.masks_to_flows(masks, use_gpu=False, device=None)[source]#

convert masks to flows using diffusion from center pixel

Center of masks where diffusion starts is defined to be the closest pixel to the median of all pixels that is inside the mask. Result of diffusion is converted into flows by computing the gradients of the diffusion density map.

Parameters

masks (int, 2D or 3D array) -- labelled masks 0=NO masks; 1,2,...=mask labels

Returns

  • mu (float, 3D or 4D array) -- flows in Y = mu[-2], flows in X = mu[-1]. if masks are 3D, flows in Z = mu[0].

  • mu_c (float, 2D or 3D array) -- for each pixel, the distance to the center of the mask in which it resides