Read the image from a give path
(path, grayscale=False)
| 39 | |
| 40 | |
| 41 | def load_img(path, grayscale=False): |
| 42 | '''Read the image from a give path''' |
| 43 | img = Image.open(path) |
| 44 | if grayscale: |
| 45 | img = img.convert('L') |
| 46 | else: # Ensure 3 channel even when loaded image is grayscale |
| 47 | img = img.convert('RGB') |
| 48 | return img |
| 49 | |
| 50 | |
| 51 | def crop(img, patch, position): |