the left and right hand subplots show the RGB image flipped a different way. This does not happen if I use PIL to read in the image using Image.open, so presumably it is a bug in imread? The files I am using can be found here.
JPG loading is handled through PIL, and the pil_to_array code explicitly flips the image upside down. This seems like a bug, but I'm hesitant to fix it since it's been that way for at least 3 years in a commit by @jdh2358 -- I'm surprised we're just finding it now -- and this isn't an area I'm terribly familiar with.
diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py
index f2d9984..93402d4 100644
--- a/lib/matplotlib/image.py
+++ b/lib/matplotlib/image.py
@@ -1257,7 +1257,7 @@ def pil_to_array( pilImage ):
"""
def toarray(im):
'return a 1D array of floats'
- x_str = im.tostring('raw',im.mode,0,-1)
+ x_str = im.tostring()
x = np.fromstring(x_str,np.uint8)
return x
Activity
mdboom commented on Apr 29, 2011
JPG loading is handled through PIL, and the pil_to_array code explicitly flips the image upside down. This seems like a bug, but I'm hesitant to fix it since it's been that way for at least 3 years in a commit by @jdh2358 -- I'm surprised we're just finding it now -- and this isn't an area I'm terribly familiar with.
diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index f2d9984..93402d4 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -1257,7 +1257,7 @@ def pil_to_array( pilImage ): """ def toarray(im): 'return a 1D array of floats' - x_str = im.tostring('raw',im.mode,0,-1) + x_str = im.tostring() x = np.fromstring(x_str,np.uint8) return xleejjoon commented on May 1, 2011
I think the thread below is related with this issue. I don't think we actually made any action though.
http://old.nabble.com/Question-about-imshow-ts23578564.html
mdboom commented on Jun 20, 2011
Changing assignment to Andrew, since I don't quite understand the history and backward incompatibility issues.
stefanv commented on Sep 19, 2011
I can verify that this is a bug. Here's the much simplified version we use in scikits.image:
https://github.com/scikits-image/scikits.image/blob/master/scikits/image/io/_plugins/pil_plugin.py#L12
mdboom commented on Jun 1, 2012
I believe this is fixed by #616.
pelson commented on Jun 10, 2012
I can confirm that this was fixed 5 days ago.
mdboom commented on Jun 11, 2012
Just a note: as this is a pretty significant backward-incompatible change, it is only on master, and won't be in the 1.1.2rc.
Merge pull request matplotlib#101 from francisco-dlp/ENH_toolkit_choice