You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RGB image is flipped a different way depending on whether it is PNG or JPG #101
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 commentedon 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 commentedon 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 commentedon Jun 20, 2011
Changing assignment to Andrew, since I don't quite understand the history and backward incompatibility issues.
stefanv commentedon 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 commentedon Jun 1, 2012
I believe this is fixed by #616.
pelson commentedon Jun 10, 2012
I can confirm that this was fixed 5 days ago.
mdboom commentedon 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