random_rotate_and_resize#

omnipose.core.random_rotate_and_resize(X, Y=None, scale_range=1.0, gamma_range=[0.75, 2.5], tyx=(224, 224), do_flip=True, rescale=None, inds=None, nchan=1)[source]#

augmentation by random rotation and resizing

X and Y are lists or arrays of length nimg, with channels x Lt x Ly x Lx (channels optional, Lt only in 3D)

Parameters
  • X (float, list of ND arrays) -- list of image arrays of size [nchan x Lt x Ly x Lx] or [Lt x Ly x Lx]

  • Y (float, list of ND arrays) -- list of image labels of size [nlabels x Lt x Ly x Lx] or [Lt x Ly x Lx]. The 1st channel of Y is always nearest-neighbor interpolated (assumed to be masks or 0-1 representation). If Y.shape[0]==3, then the labels are assumed to be [distance, T flow, Y flow, X flow].

  • links (list of label links) -- lists of label pairs linking parts of multi-label object together this is how omnipose gets around boudary artifacts druing image warps

  • scale_range (float (optional, default 1.0)) -- Range of resizing of images for augmentation. Images are resized by (1-scale_range/2) + scale_range * np.random.rand()

  • gamma_range (float, list) -- images are gamma-adjusted im**gamma for gamma in [low,high]

  • tyx (int, tuple) -- size of transformed images to return, e.g. (Ly,Lx) or (Lt,Ly,Lx)

  • do_flip (bool (optional, default True)) -- whether or not to flip images horizontally

  • rescale (float, array or list) -- how much to resize images by before performing augmentations

  • inds (int, list) -- image indices (for debugging)

  • nchan (int) -- number of channels the images have

Returns

  • imgi (float, ND array) -- transformed images in array [nimg x nchan x xy[0] x xy[1]]

  • lbl (float, ND array) -- transformed labels in array [nimg x nchan x xy[0] x xy[1]]

  • scale (float, 1D array) -- scalar(s) by which each image was resized