(path, grayscale=False)
| 8 | |
| 9 | |
| 10 | def read_image(path, grayscale=False): |
| 11 | if grayscale: |
| 12 | mode = cv2.IMREAD_GRAYSCALE |
| 13 | else: |
| 14 | mode = cv2.IMREAD_COLOR |
| 15 | image = cv2.imread(str(path), mode) |
| 16 | if image is None: |
| 17 | raise ValueError(f'Cannot read image {path}.') |
| 18 | if not grayscale and len(image.shape) == 3: |
| 19 | image = image[:, :, ::-1] # BGR to RGB |
| 20 | return image |
| 21 | |
| 22 | |
| 23 | def list_h5_names(path): |
no outgoing calls
no test coverage detected