[Numpy-discussion] bug using array with a PIL Image (misc.imread)

Nicolas Pinto pinto@mit....
Tue Jul 7 19:07:22 CDT 2009


Dear all,

For some reason I have a problem converting a specific png image using
array().

Here is what I am getting (using numpy 1.3.0 and scipy 0.7.0).

% wget http://files.getdropbox.com/u/167753/spiky_adj_023.png
% python -c "import numpy as np; import Image; print
np.array(Image.open('spiky_adj_023.png'))"
<PngImagePlugin.PngImageFile instance at 0xd1a050>

% wget http://files.getdropbox.com/u/167753/spiky_norm_001.png
% python -c "import numpy as np; import Image; print
np.array(Image.open('spiky_norm_001.png'))"
[[134  30 140 ..., 230  83  59]
 [ 99 202 233 ..., 160  63 133]
 [ 93 241  35 ...,   7 240 101]
 ...,
 [206 132 196 ..., 139 190 112]
 [218  21 217 ..., 121 152 109]
 [ 83 188 187 ...,   6 240 251]]


I was initially using scipy's misc.imread when I found this bug. I am
currently using the following workaround:
% python -c "import numpy as np; import Image; print
np.array(Image.open('spiky_adj_023.png').convert('RGB'))"

Let me know what you think.

Thanks in advance.

Sincerely,

-- 
Nicolas Pinto
Ph.D. Candidate, Brain & Computer Sciences
Massachusetts Institute of Technology, USA
http://web.mit.edu/pinto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090707/de1b5ce0/attachment-0001.html 


More information about the NumPy-Discussion mailing list