def save_image(filepath, image):
"""
Save numpy array as image (or numpy array) to given filepath.
Supported formats: gif, png, jpg, bmp, tif, npy
:param string filepath: File path for image file. Extension determines
image file format, e.g. .gif
:param numpy array image: Numpy array to save as image.
Must be of shape (h,w) or (h,w,3) or (h,w,4)
"""
if filepath.endswith('.npy'): # image as numpy array
np.save(filepath, image, allow_pickle=False)
else:
ski.imsave(filepath, image)
评论列表
文章目录