random_rotate_and_resize#

cellpose_omni.transforms.random_rotate_and_resize(X, Y=None, scale_range=1.0, gamma_range=[0.5, 4], tyx=None, do_flip=True, rescale=None, unet=False, inds=None, omni=False, dim=2, nchan=1, nclasses=3, device=None)[source]#

augmentation by random rotation and resizing

X and Y are lists or arrays of length nimg, with dims channels x Ly x Lx (channels optional)

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

  • Y (LIST of ND-arrays, float (optional, default None)) -- list of image labels of size [nlabels x Ly x Lx] or [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 and not unet, then the labels are assumed to be [cell probability, Y flow, X flow]. If unet, second channel is dist_to_bound.

  • 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 (optional, default 0.5)) -- Images are gamma-adjusted im**gamma for gamma in (1-gamma_range,1+gamma_range)

  • xy (tuple, int (optional, default (224,224))) -- size of transformed images to return

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

  • rescale (array, float (optional, default None)) -- how much to resize images by before performing augmentations

  • unet (bool (optional, default False)) --

Returns

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

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

  • scale (array, float) -- amount each image was resized by