(image, crop_factors)
| 219 | |
| 220 | |
| 221 | def crop(image, crop_factors): |
| 222 | target_h, target_w = crop_factors |
| 223 | img_w, img_h = image.size |
| 224 | |
| 225 | if target_h > img_h or target_w > img_w: |
| 226 | raise ValueError("Crop size exceeds image dimensions") |
| 227 | |
| 228 | x = random.randint(0, img_w - target_w) |
| 229 | y = random.randint(0, img_h - target_h) |
| 230 | |
| 231 | return image.crop((x, y, x + target_w, y + target_h)), [[x, y], [x + target_w, y + target_h]] |
| 232 | |
| 233 | |
| 234 | def motion_blur_opencv(image, kernel_size=15, angle=0): |