MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / generate_random_crop_pos

Function generate_random_crop_pos

utils/transforms.py:44–59  ·  view source on GitHub ↗
(ori_size, crop_size)

Source from the content-addressed store, hash-verified

42
43
44def generate_random_crop_pos(ori_size, crop_size):
45 ori_size = get_2dshape(ori_size)
46 h, w = ori_size
47
48 crop_size = get_2dshape(crop_size)
49 crop_h, crop_w = crop_size
50
51 pos_h, pos_w = 0, 0
52
53 if h > crop_h:
54 pos_h = random.randint(0, h - crop_h + 1)
55
56 if w > crop_w:
57 pos_w = random.randint(0, w - crop_w + 1)
58
59 return pos_h, pos_w
60
61
62def pad_image_to_shape(img, shape, border_mode, value):

Callers 1

__call__Method · 0.90

Calls 1

get_2dshapeFunction · 0.85

Tested by

no test coverage detected