(self, img)
| 473 | return img_padded |
| 474 | |
| 475 | def random_crop(self, img): |
| 476 | h, w = img.shape[:2] |
| 477 | max_x = w - self.width |
| 478 | max_y = h - self.height |
| 479 | |
| 480 | x = np.random.randint(0, max_x) |
| 481 | y = np.random.randint(0, max_y) |
| 482 | |
| 483 | crop = img[y:y+self.height,x:x+self.width] |
| 484 | return crop |
| 485 | |
| 486 | def random_brightness(self, img, binary_mask=None): |
| 487 | if np.random.rand() <= 0.5: |