random crop
(image)
| 118 | |
| 119 | |
| 120 | def get_crop(image): |
| 121 | """ |
| 122 | random crop |
| 123 | """ |
| 124 | h, w, _ = image.shape |
| 125 | top_min = 1 |
| 126 | top_max = 5 |
| 127 | top_crop = int(random.randint(top_min, top_max)) |
| 128 | top_crop = min(top_crop, h - 1) |
| 129 | crop_img = image.copy() |
| 130 | ratio = random.randint(0, 1) |
| 131 | if ratio: |
| 132 | crop_img = crop_img[top_crop:h, :, :] |
| 133 | else: |
| 134 | crop_img = crop_img[0:h - top_crop, :, :] |
| 135 | return crop_img |
| 136 | |
| 137 | |
| 138 | def resizeAug(img, HThresh=25): |