Title: PIL-opened image and imread-opened image render slightly differently in classic mode · Issue #14340 · matplotlib/matplotlib · GitHub
Open Graph Title: PIL-opened image and imread-opened image render slightly differently in classic mode · Issue #14340 · matplotlib/matplotlib
X Title: PIL-opened image and imread-opened image render slightly differently in classic mode · Issue #14340 · matplotlib/matplotlib
Description: Bug report Bug summary Per the title. Code for reproduction from pathlib import Path import matplotlib as mpl from matplotlib.testing.compare import compare_images from matplotlib import pyplot as plt, style from PIL import Image mpl.use...
Open Graph Description: Bug report Bug summary Per the title. Code for reproduction from pathlib import Path import matplotlib as mpl from matplotlib.testing.compare import compare_images from matplotlib import pyplot as ...
X Description: Bug report Bug summary Per the title. Code for reproduction from pathlib import Path import matplotlib as mpl from matplotlib.testing.compare import compare_images from matplotlib import pyplot as ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/14340
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PIL-opened image and imread-opened image render slightly differently in classic mode","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nPer the title.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\n```python\r\nfrom pathlib import Path\r\nimport matplotlib as mpl\r\nfrom matplotlib.testing.compare import compare_images\r\nfrom matplotlib import pyplot as plt, style\r\nfrom PIL import Image\r\n\r\nmpl.use(\"agg\")\r\nmpl.style.use(\"classic\")\r\n\r\npath = str(Path(mpl.__file__).parent / \"tests/baseline_images/pngsuite/basn3p04.png\")\r\n\r\nfig = plt.figure()\r\nfig.subplots().imshow(plt.imread(path))\r\nfig.savefig(\"1.png\")\r\nfig = plt.figure()\r\nfig.subplots().imshow(Image.open(path))\r\nfig.savefig(\"2.png\")\r\nprint(compare_images(\"1.png\", \"2.png\", tol=0))\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\nError: Image files did not match.\r\n RMS Value: 0.010865337342004415\r\n Expected: \r\n 1.png\r\n Actual: \r\n 2.png\r\n Difference:\r\n 2-failed-diff.png\r\n Tolerance: \r\n 0\r\n```\r\n\r\n**Expected outcome**\r\n\r\nNo diff.\r\n\r\nI *think* this may possibly(???) be due to rounding errors when imread converts from 0-255 (uint8) to 0-1 (float) and then imshow converts back to 0-255 (uint8)?\r\n\r\nNote that this does not occur when using the mpl20 default style.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: linux\r\n * Matplotlib version: master\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): agg\r\n * Python version: 3.7\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2019-05-27T09:49:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/14340/matplotlib/issues/14340"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4a2470de-f406-1f08-6782-63a69a435843 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD7E:3C777:12956B5:1AAD343:6A58A6DC |
| html-safe-nonce | 69ad2851f3e31cd2882da6b1d9b454db4f3cec6888bf8e96f06e7685ab729dd4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDdFOjNDNzc3OjEyOTU2QjU6MUFBRDM0Mzo2QTU4QTZEQyIsInZpc2l0b3JfaWQiOiIyNDQ3NTM2MTQyNDYxNDc4NjIwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ab81d4701c7824d39983057a23253fff3eb249cbb2f6b01ac76815d3447da4e9 |
| hovercard-subject-tag | issue:448766297 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/14340/issue_layout |
| twitter:image | https://opengraph.githubassets.com/edd694df4c8f1d1b319cb30e6ad07068a62d4b2b75efee72bfa6359d7c0afa79/matplotlib/matplotlib/issues/14340 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/edd694df4c8f1d1b319cb30e6ad07068a62d4b2b75efee72bfa6359d7c0afa79/matplotlib/matplotlib/issues/14340 |
| og:image:alt | Bug report Bug summary Per the title. Code for reproduction from pathlib import Path import matplotlib as mpl from matplotlib.testing.compare import compare_images from matplotlib import pyplot as ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width