Debian Codegraph @

imgviz/utils.py

raw symbols SCIP
1 import numpy as np
2 import PIL.Image
3
4
5 def pillow_to_numpy(img):
6 img_numpy = np.asarray(img)
7 if not img_numpy.flags.writeable:
8 img_numpy = np.array(img)
9 return img_numpy
10
11
12 def numpy_to_pillow(img, mode=None):
13 img_pillow = PIL.Image.fromarray(img, mode=mode)
14 return img_pillow