Save a numpy image to the disk Parameters: image_numpy (numpy array) -- input numpy array image_path (str) -- the path of the image
(image_numpy, image_path, aspect_ratio=1.0)
| 45 | |
| 46 | |
| 47 | def save_image(image_numpy, image_path, aspect_ratio=1.0): |
| 48 | """Save a numpy image to the disk |
| 49 | |
| 50 | Parameters: |
| 51 | image_numpy (numpy array) -- input numpy array |
| 52 | image_path (str) -- the path of the image |
| 53 | """ |
| 54 | image_pil = Image.fromarray(image_numpy) |
| 55 | |
| 56 | image_pil = image_pil.convert('I;16') |
| 57 | |
| 58 | # image_pil = Image.fromarray(image_numpy) |
| 59 | # h, w, _ = image_numpy.shape |
| 60 | # |
| 61 | # if aspect_ratio > 1.0: |
| 62 | # image_pil = image_pil.resize((h, int(w * aspect_ratio)), Image.BICUBIC) |
| 63 | # if aspect_ratio < 1.0: |
| 64 | # image_pil = image_pil.resize((int(h / aspect_ratio), w), Image.BICUBIC) |
| 65 | |
| 66 | image_pil.save(image_path) |
| 67 | |
| 68 | |
| 69 | def print_numpy(x, val=True, shp=False): |