Created
April 6, 2015 08:54
-
-
Save t2psyto/5531f6f54495d1b3515e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wand2pil(image): | |
width, height = image.size | |
depth = image.depth | |
if image.colorspace == 'gray': | |
channs = 1 | |
fmt = 'gray' | |
else: | |
channs = 3 | |
fmt = 'RGB' | |
image.depth = 16 | |
imgArray = np.ndarray((height, width, channs), dtype='uint16', buffer=image.make_blob(fmt)) | |
c = numpy.uint8(imgArray) | |
pilImg = Image.fromarray(c) | |
return pilImg | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment