MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / CenterCrop

Class CenterCrop

utils/joint_transforms.py:46–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45
46class CenterCrop(object):
47 def __init__(self, size):
48 if isinstance(size, numbers.Number):
49 self.size = (int(size), int(size))
50 else:
51 self.size = size
52
53 def __call__(self, img, mask):
54 assert img.size == mask.size
55 w, h = img.size
56 th, tw = self.size
57 x1 = int(round((w - tw) / 2.))
58 y1 = int(round((h - th) / 2.))
59 return img.crop((x1, y1, x1 + tw, y1 + th)), mask.crop((x1, y1, x1 + tw, y1 + th))
60
61
62class RandomHorizontallyFlip(object):

Callers 1

__call__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected