MCPcopy Create free account
hub / github.com/chenhaoxing/HDNet / save_image

Function save_image

util/util.py:49–64  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected