Merge pull request #89 from cgohlke/patch-4

BUG: Workaround 16 bit image to numpy array conversion bug in PIL.
This commit is contained in:
Stefan van der Walt
2011-12-05 16:09:26 -08:00
+5 -1
View File
@@ -20,7 +20,11 @@ def imread(fname, dtype=None):
else:
im = im.convert('RGB')
if 'A' in im.mode:
if im.mode == 'I;16':
shape = im.size
im = np.fromstring(im.tostring(), dtype=np.uint16)
im.shape = shape[::-1]
elif 'A' in im.mode:
im = im.convert('RGBA')
return np.array(im, dtype=dtype)