Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: I give an RGB image to imsave but I don't have the right color map! #29183

Closed
Labels
Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!status: confirmed bug
Milestone
@zef126

Description

@zef126

Bug summary

When I give an RGB image as a list of list of list to imsave, I don't have the right colormap and there is no rgb colormap!

Code for reproduction

importmatplotlib.pyplotaspltI=plt.imread("notre-dame.jpg")m,n,p=I.shape#m=largeur, n=hauteur, p=upletJ=[[[0fordinrange(p)]foreinrange(n)]forfinrange(m)]K=[[[0fordinrange(p)]foreinrange(n)]forfinrange(m)]L=[[[0fordinrange(p)]foreinrange(n)]forfinrange(m)]foriinrange(m) :forjinrange(n) :J[i][j]=[int(I[i][j][0]),0,0]K[i][j]=[0,int(I[i][j][1]),0]L[i][j]=[0,0,int(I[i][j][2])]fig,ax=plt.subplots(4,figsize=(28,10))ax[0].imshow(I)ax[1].imshow(J)ax[2].imshow(K)ax[3].imshow(L)ax[0].set_axis_off()ax[1].set_axis_off()ax[2].set_axis_off()ax[3].set_axis_off()ax[0].set_title('Image complete')ax[1].set_title('Composante rouge')ax[2].set_title('Composante bleue')ax[3].set_title('Composante verte')fig.suptitle("Image de Notre-Dame",x=0.51,y=.93)plt.imsave("Notre-Dame_rouge.png",J)#The problem is here!plt.savefig("Notre-Dame_composante_ex1.png",dpi=750,bbox_inches="tight")plt.savefig("Notre-Dame_composante_ex1.pdf",dpi=750,bbox_inches="tight")plt.show()

Actual outcome

Notre-Dame_rouge

Expected outcome

Notre-Dame_composante_ex1
The red one in a png image!

Additional information

notre-dame
The original image

Operating system

Win 11

Matplotlib Version

3.9.2

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.11.10

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!status: confirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp