Title: imsave and imshow ignore vmin/vmax · Issue #5382 · matplotlib/matplotlib · GitHub
Open Graph Title: imsave and imshow ignore vmin/vmax · Issue #5382 · matplotlib/matplotlib
X Title: imsave and imshow ignore vmin/vmax · Issue #5382 · matplotlib/matplotlib
Description: I'm sure this should be already known, but I couldn't find any issue related to this. As far as I can tell, imsave and imshow expect arrays of floats to be from 0 to 1, and arrays of uint8 to be from 0 to 255. In both cases, the vmin and...
Open Graph Description: I'm sure this should be already known, but I couldn't find any issue related to this. As far as I can tell, imsave and imshow expect arrays of floats to be from 0 to 1, and arrays of uint8 to be fr...
X Description: I'm sure this should be already known, but I couldn't find any issue related to this. As far as I can tell, imsave and imshow expect arrays of floats to be from 0 to 1, and arrays of uint8 ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/5382
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"imsave and imshow ignore vmin/vmax","articleBody":"I'm sure this should be already known, but I couldn't find any issue related to this.\n\nAs far as I can tell, imsave and imshow expect arrays of floats to be from 0 to 1, and arrays of uint8 to be from 0 to 255. In both cases, the vmin and vmax arguments are completely ignored.\n\nThe following code shows the issue with imsave, and I'm attaching the resulting images. It was tested with matplotlib 1.5.0 and numpy 1.8.2.\n\n``` python\nimport matplotlib\nprint matplotlib.__version__ ## 1.5.0\n\nimport matplotlib.image as im\na = im.imread('lena.jpg')\n\nprint 'a: ', a.min(), a.max(), a.dtype ## a: 0 255 uint8\n# This works fine\nim.imsave('test0.png', a)\n\n# vmin and vmax are ignored. Expected a saturated image\nim.imsave('test1.png', a, vmin=0, vmax=128)\na_expected = a.astype('float')/128\nim.imsave('test1_expected.png', a_expected)\n\nb = a.astype('float')\nprint 'b: ', b.min(), b.max(), b.dtype ## b: 0.0 255.0 float64\n# imsave should use b.min() and b.max() as limits.\nim.imsave('test2.png', b)\nim.imsave('test2_expected.png', b/255)\n\n# vmin and vmax are ignored. Expected an image equal to the original\nim.imsave('test3.png', b, vmin=0, vmax=255)\nim.imsave('test3_expected.png', b/255)\n\nc = b / b.max()\nprint 'c: ', c.min(), c.max(), c.dtype ##c: 0.0 1.0 float64\n# This works fine\nim.imsave('test4.png', c)\n\n# vmin and vmax are ignored. Expected a saturated image\nim.imsave('test5.png', c, vmin=0, vmax=0.5)\nim.imsave('test5_expected.png', c*2)\n```\n\n original\n test0\n test1\n test1_expected\n test2\n test2_expected\n test3\n test3_expected\n test4\n test5\n test5_expected\n","author":{"url":"https://github.com/Arnoques","@type":"Person","name":"Arnoques"},"datePublished":"2015-11-02T21:23:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/5382/matplotlib/issues/5382"}
| 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:37f53fc3-a638-db1b-51ad-399ca48a05a7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A8F0:134AC6:58B46F:783FC3:6A527D9D |
| html-safe-nonce | 95eaf96deab3ef83c94c60fe9d48a730c222df3cfb00566e3c93b3b9615ca0a2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEYwOjEzNEFDNjo1OEI0NkY6NzgzRkMzOjZBNTI3RDlEIiwidmlzaXRvcl9pZCI6IjY3MzQ1NTA2ODM3NDIyNzI5MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bb76cb35d0bf338d187eeb135c63f56c0e91c3558263d94a031b817bead2b0da |
| hovercard-subject-tag | issue:114686942 |
| 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/5382/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c7ba98d0ec1899740e81f42f6da38ac3479e0a42369479cc777cebbdf50aeb14/matplotlib/matplotlib/issues/5382 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c7ba98d0ec1899740e81f42f6da38ac3479e0a42369479cc777cebbdf50aeb14/matplotlib/matplotlib/issues/5382 |
| og:image:alt | I'm sure this should be already known, but I couldn't find any issue related to this. As far as I can tell, imsave and imshow expect arrays of floats to be from 0 to 1, and arrays of uint8 to be fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Arnoques |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width