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

Class ScaleMin

transforms/joint_transforms.py:347–369  ·  view source on GitHub ↗

Scale image such that shorter side is == size

Source from the content-addressed store, hash-verified

345
346
347class ScaleMin(object):
348 """
349 Scale image such that shorter side is == size
350 """
351
352 def __init__(self, size):
353 self.size = size
354
355 def __call__(self, img, mask):
356 assert img.size == mask.size
357 w, h = img.size
358 if (w <= h and w == self.size) or (h <= w and h == self.size):
359 return img, mask
360 if w < h:
361 ow = self.size
362 oh = int(self.size * h / w)
363 return img.resize((ow, oh), Image.BICUBIC), mask.resize(
364 (ow, oh), Image.NEAREST)
365 else:
366 oh = self.size
367 ow = int(self.size * w / h)
368 return img.resize((ow, oh), Image.BICUBIC), mask.resize(
369 (ow, oh), Image.NEAREST)
370
371
372class Resize(object):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected