Title: matplotlib.pyplot.imsave colormaps some grayscale images before saving them · Issue #3657 · matplotlib/matplotlib · GitHub
Open Graph Title: matplotlib.pyplot.imsave colormaps some grayscale images before saving them · Issue #3657 · matplotlib/matplotlib
X Title: matplotlib.pyplot.imsave colormaps some grayscale images before saving them · Issue #3657 · matplotlib/matplotlib
Description: Some people may be using matplotlib as an image IO library. Those people may also be scientists that care about their data being accurately saved on disk. They will be disappointed, however, to find that imsave does nothing of the sort: ...
Open Graph Description: Some people may be using matplotlib as an image IO library. Those people may also be scientists that care about their data being accurately saved on disk. They will be disappointed, however, to fin...
X Description: Some people may be using matplotlib as an image IO library. Those people may also be scientists that care about their data being accurately saved on disk. They will be disappointed, however, to fin...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/3657
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"matplotlib.pyplot.imsave colormaps some grayscale images before saving them","articleBody":"Some people may be using matplotlib as an image IO library. Those people may also be scientists that care about their data being accurately saved on disk. They will be disappointed, however, to find that `imsave` does nothing of the sort:\n\n``` python\nIn [8]: mpl.pyplot.imsave('io4.png', np.array([[0, 1], [0, 4196]], dtype=np.uint16))\n\nIn [10]: im4 = mpl.pyplot.imread('io4.png')\n\nIn [11]: im4.shape\nOut[11]: (2, 2, 4)\n\nIn [12]: np.rollaxis(im4, -1) # display the three channels + alpha of the array\nOut[12]: \narray([[[ 0. , 0. ],\n [ 0. , 0.49803922]],\n\n [[ 0. , 0. ],\n [ 0. , 0. ]],\n\n [[ 0.49803922, 0.49803922],\n [ 0.49803922, 0. ]],\n\n [[ 1. , 1. ],\n [ 1. , 1. ]]], dtype=float32)\n```\n\nWhat is happening here is that `imsave` has encountered a data type it's not happy with (uint16, a commonly used data format in microscopy and probably other scientific imaging), and decided to silently colormap the values and save them as a uint8 RGBA image. (See #3616 for a longer discussion.) Adding insult to injury, the color mapping is to jet.\n\nIn summary:\n- Observed behaviour: imsave colormaps certain images before saving as uint8 RBGA.\n- Desired behaviour: either save the data exactly as given, or raise a ValueError, or at the very least raise a warning.\n","author":{"url":"https://github.com/jni","@type":"Person","name":"jni"},"datePublished":"2014-10-17T13:57:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/3657/matplotlib/issues/3657"}
| 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:47270d0d-2b63-aad6-8a05-9e007793ae5e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BF2:1C39AB:32C6F0:45774D:6A51421F |
| html-safe-nonce | a1f9876bd36f878a13164475c6bce686f4ba1a3705d811479e90a5b64c33e524 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkYyOjFDMzlBQjozMkM2RjA6NDU3NzREOjZBNTE0MjFGIiwidmlzaXRvcl9pZCI6IjIzNDQ1MDA5MDc4MjIxMDUxMTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a533357476647ca91cac784e717e9469454338ab833ad40de025019d029c8a43 |
| hovercard-subject-tag | issue:46102035 |
| 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/3657/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c4c413716d67203cb666edc7058661f9b9b2547bc629950e9ebf8127f66253e9/matplotlib/matplotlib/issues/3657 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c4c413716d67203cb666edc7058661f9b9b2547bc629950e9ebf8127f66253e9/matplotlib/matplotlib/issues/3657 |
| og:image:alt | Some people may be using matplotlib as an image IO library. Those people may also be scientists that care about their data being accurately saved on disk. They will be disappointed, however, to fin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jni |
| hostname | github.com |
| expected-hostname | github.com |
| None | e840f405b2718e8f2d55aafa9ff27dbce17e29d0c253011d05ea0fea3c78baff |
| 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 | e876f00c5723f6080b9d294e4958fd4d506e6faf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width