MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / randomCrop

Function randomCrop

utils/data_val.py:33–42  ·  view source on GitHub ↗
(image, label, edge)

Source from the content-addressed store, hash-verified

31 return img, label
32
33def randomCrop(image, label, edge):
34 border = 30
35 image_width = image.size[0]
36 image_height = image.size[1]
37 crop_win_width = np.random.randint(image_width - border, image_width)
38 crop_win_height = np.random.randint(image_height - border, image_height)
39 random_region = (
40 (image_width - crop_win_width) >> 1, (image_height - crop_win_height) >> 1, (image_width + crop_win_width) >> 1,
41 (image_height + crop_win_height) >> 1)
42 return image.crop(random_region), label.crop(random_region), edge.crop(random_region)
43
44def randomCrop_noEdge(image, label):
45 border = 30

Callers 3

__getitem__Method · 0.85
__getitem__Method · 0.85
__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected