MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / new_Scale

Class new_Scale

transforms/joint_transforms.py:322–344  ·  view source on GitHub ↗

Scale image such that longer side is == size

Source from the content-addressed store, hash-verified

320
321
322class new_Scale(object):
323 """
324 Scale image such that longer side is == size
325 """
326
327 def __init__(self, size):
328 self.size = size
329
330 def __call__(self, img, mask):
331 assert img.size == mask.size
332 w, h = img.size
333 if (w >= h and w == self.size) or (h >= w and h == self.size):
334 return img, mask
335 if w > h:
336 ow = self.size
337 oh = int(self.size * h / w)
338 return img.resize((ow, oh), Image.BICUBIC), mask.resize(
339 (ow, oh), Image.NEAREST)
340 else:
341 oh = self.size
342 ow = int(self.size * w / h)
343 return img.resize((ow, oh), Image.BICUBIC), mask.resize(
344 (ow, oh), Image.NEAREST)
345
346
347class ScaleMin(object):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected