Args: num_case: num of resize cases, must be <= the length of size_list inplace: inplace imgs or not ( return new_imgs)
(self, size_list, num_case=1, inplace=True)
| 274 | return self.resize_by_list(size_list, 1, inplace) |
| 275 | |
| 276 | def resize_by_list(self, size_list, num_case=1, inplace=True): |
| 277 | ''' |
| 278 | Args: |
| 279 | num_case: num of resize cases, must be <= the length of size_list |
| 280 | inplace: inplace imgs or not ( return new_imgs) |
| 281 | ''' |
| 282 | new_imgs = [] |
| 283 | if num_case < 1 or num_case > len(size_list): |
| 284 | raise Exception( |
| 285 | 'num_case must be smaller in [0,%d(length of size_list)]' % |
| 286 | len(size_list)) |
| 287 | for img in self.imgs: |
| 288 | if num_case == len(size_list): |
| 289 | small_sizes = size_list |
| 290 | else: |
| 291 | small_sizes = get_list_sample(size_list, num_case) |
| 292 | |
| 293 | for small_size in small_sizes: |
| 294 | new_img = resize(img, small_size) |
| 295 | new_imgs.append(new_img) |
| 296 | if inplace: |
| 297 | self.imgs = new_imgs |
| 298 | return self |
| 299 | else: |
| 300 | return new_imgs |
| 301 | |
| 302 | def resize_by_hw_range(self, rng, inplace=True): |
| 303 | ''' |
no test coverage detected