GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #101

New issue
Copy link
New issue
Copy link
Closed
Closed
RGB image is flipped a different way depending on whether it is PNG or JPG#101
Copy link
Assignees
astraw
Milestone
v1.0.x

Description

@astrofrog
astrofrog
opened on Apr 29, 2011
Issue body actions

If 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.

Activity

  1. mdboom commented on Apr 29, 2011

    @mdboom
    mdboom
    on Apr 29, 2011
    Member
    More actions

    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
     
  2. leejjoon commented on May 1, 2011

    @leejjoon
    leejjoon
    on May 1, 2011
    Contributor
    More actions

    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

  3. ghost assigned
    mdboom
    on Jun 15, 2011
  4. ghost assigned
    astraw
    on Jun 20, 2011
  5. mdboom commented on Jun 20, 2011

    @mdboom
    mdboom
    on Jun 20, 2011
    Member
    More actions

    Changing assignment to Andrew, since I don't quite understand the history and backward incompatibility issues.

  6. stefanv commented on Sep 19, 2011

    @stefanv
    stefanv
    on Sep 19, 2011
    Contributor
    More actions

    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

  7. mdboom commented on Jun 1, 2012

    @mdboom
    mdboom
    on Jun 1, 2012
    Member
    More actions

    I believe this is fixed by #616.

  8. pelson commented on Jun 10, 2012

    @pelson
    pelson
    on Jun 10, 2012
    Member
    More actions

    I can confirm that this was fixed 5 days ago.

  9. pelson
    closed this as completedon Jun 10, 2012
  10. mdboom commented on Jun 11, 2012

    @mdboom
    mdboom
    on Jun 11, 2012
    Member
    More actions

    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.

  11. magnunor
    added a commit that references this issue on Dec 5, 2013

    Merge pull request matplotlib#101 from francisco-dlp/ENH_toolkit_choice

    611f11c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @astraw
    astraw

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    • v1.0.x

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.