Scale image such that shorter side is == size
| 345 | |
| 346 | |
| 347 | class 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 | |
| 372 | class Resize(object): |
nothing calls this directly
no outgoing calls
no test coverage detected