MCPcopy Create free account
hub / github.com/PyWavelets/pywt / image2array

Function image2array

demo/image_blender.py:55–60  ·  view source on GitHub ↗

PIL Image to NumPy array

(image)

Source from the content-addressed store, hash-verified

53
54
55def image2array(image):
56 """PIL Image to NumPy array"""
57 assert image.mode in ('L', 'RGB', 'CMYK')
58 arr = numpy.fromstring(image.tobytes(), numpy.uint8)
59 arr.shape = (image.size[1], image.size[0], len(image.getbands()))
60 return arr.swapaxes(0, 2).swapaxes(1, 2).astype(numpy.float32)
61
62
63def array2image(arr, mode):

Callers 1

blend_imagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected