MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / compute_crop_size

Function compute_crop_size

utils/general_util.py:384–404  ·  view source on GitHub ↗
(mask)

Source from the content-addressed store, hash-verified

382
383
384def compute_crop_size(mask):
385 H,W = mask.shape[:2]
386 index = np.nonzero(mask)
387 left = np.min(index[1])
388 right = np.max(index[1])
389 top = np.min(index[0])
390 bottom = np.max(index[0])
391 horizontal = H - (right-left)
392 vertical = W - (bottom-top)
393 crop_size = max(horizontal,vertical)
394 crop_size = random.randint(0,crop_size)
395 ratio_left = left/(horizontal)
396
397 ratio_top = top/(vertical)
398
399 crop_left = int(ratio_left*crop_size)
400 crop_right = W - crop_size + crop_left
401 crop_top = int(ratio_top*crop_size)
402
403 crop_bottom = H -crop_size + crop_top
404 return crop_left,crop_right,crop_top,crop_bottom
405
406
407def dilate_erode_mask(mask):

Callers

nothing calls this directly

Calls 2

minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected