MCPcopy Create free account
hub / github.com/KerenLab/CellSighter / env_shape_aug

Function env_shape_aug

data/transform.py:36–47  ·  view source on GitHub ↗

Augment the size of the cells mask in the environment, by dilating the size of the cell with random kernel

(x)

Source from the content-addressed store, hash-verified

34
35
36def env_shape_aug(x):
37 """
38 Augment the size of the cells mask in the environment,
39 by dilating the size of the cell with random kernel
40 """
41 if np.random.random() < 0.5:
42 cell_mask = x[:, :, -2]
43 kernel_size = np.random.choice([2, 3, 5])
44 kernel = np.ones(kernel_size, np.uint8)
45 img_dilation = cv2.dilate(cell_mask, kernel, iterations=1)
46 x[:, :, -2] = img_dilation
47 return x
48
49
50val_transform = lambda crop_size: torchvision.transforms.Compose([

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected