GeezerVison is showing github.com — RGB image is flipped a different way depending on whether it is PNG or JPG · Issue #101 · matplotlib/matplotlib
RGB image is flipped a different way depending on whether it is PNG or JPG #101DescriptionIf I run the following example
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1,2,1)
image = plt.imread('2mass_rgb.png')
ax.imshow(image, origin='upper', extent=[0.5,723.5,0.5,724.5])
ax = fig.add_subplot(1,2,2)
image = plt.imread('2mass_rgb.jpg')
ax.imshow(image, origin='upper', extent=[0.5,723.5,0.5,724.5])
fig.savefig('rgb.png')
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. Activitymdboom 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 x
leejjoon commented on May 1, 2011 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 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|