Scale image such that longer side is == size
| 320 | |
| 321 | |
| 322 | class 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 | |
| 347 | class ScaleMin(object): |
nothing calls this directly
no outgoing calls
no test coverage detected