Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fixed imsave() saving incorrect color map#29203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
07226ab
e491c52
e4bdd84
c16b4b0
3faf4e2
0df1f51
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -5869,6 +5869,7 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None, | ||||
`~matplotlib.pyplot.imshow` expects RGB images adopting the straight | ||||
(unassociated) alpha representation. | ||||
""" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change | ||||
im = mimage.AxesImage(self, cmap=cmap, norm=norm, colorizer=colorizer, | ||||
interpolation=interpolation, origin=origin, | ||||
extent=extent, filternorm=filternorm, | ||||
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -28,6 +28,7 @@ | ||||
Affine2D, BboxBase, Bbox, BboxTransform, BboxTransformTo, | ||||
IdentityTransform, TransformedBbox) | ||||
_log = logging.getLogger(__name__) | ||||
# map interpolation strings to module constants | ||||
@@ -1093,6 +1094,7 @@ def set_data(self, x, y, A): | ||||
""" | ||||
Set the grid for the pixel centers, and the pixel values. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change | ||||
Parameters | ||||
---------- | ||||
x, y : 1D array-like | ||||
@@ -1582,6 +1584,10 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None, | ||||
_api.check_in_list(('upper', 'lower'), origin=origin) | ||||
if origin == "lower": | ||||
arr = arr[::-1] | ||||
if (isinstance(arr, list)): | ||||
arr = np.asarray(arr, dtype=np.uint8) | ||||
Comment on lines +1587 to +1590 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Let's move the format coersion above the origin handling. While the reversal ( Also
| ||||
if (isinstance(arr, memoryview) and arr.format == "B" | ||||
and arr.ndim == 3 and arr.shape[-1] == 4): | ||||
# Such an ``arr`` would also be handled fine by sm.to_rgba below | ||||
@@ -1630,6 +1636,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None, | ||||
background = PIL.Image.new("RGB", pil_shape, color) | ||||
background.paste(image, image) | ||||
image = background | ||||
pil_kwargs.setdefault("format", format) | ||||
pil_kwargs.setdefault("dpi", (dpi, dpi)) | ||||
image.save(fname, **pil_kwargs) | ||||
Uh oh!
There was an error while loading.Please reload this page.