简体   繁体   中英

How do I save a matplotlib figure in the normalized [0,1] range?

I am generating annotation files for image segmentation learning. For that I am relying on matplotlibs fill_between() method. I need to save the figure borderless and in a value range of [0,1].

How do I do that?

I found out that fig.savefig() can pass arguments to the pillow backend when saving as.png, however i can not find the right arguments to pass to save it in [0,1] range instead of [0,255]

You can't save a png image in a real valued range of [0,1] . Image intensity values in RGB format are only defined for natural numbers of [0,255] . It would also makes little sense to visualise an image with such low intensity values, because it would appear pretty much black.

What you could do instead if you are interested in persisting your data is normalising your matrix to your range and save it as a numpy array instead using numpys save() function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM