如何使用透明背景保存图形 [英] How to save figure with transparent background

查看:73
本文介绍了如何使用透明背景保存图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Matlab中有一个图,并通过以下方式将背景设置为透明:

I have a plot in Matlab and am setting the background to transparent by:

set(gcf, 'Color', 'None');
set(gca, 'Color', 'None');

当我尝试保存图像(从查看器中保存)时,我另存为".png",但保存时带有白色背景.如何在透明背景下保存它?

When I try to save the image (from the viewer), I save as a ".png", but it saves with a white background. How can I save it with the transparent background?

推荐答案

令人失望的是,但是MATLAB的默认 saveas print 命令不能很好地处理透明事物.您必须将其保存一些背景,然后通过 imread / imwrite 或其他工具进行转换.

It is disappointing but, MATLAB's default saveas and print commands cannot deal with transparent things very well. You'll have to save it with some background and then convert it either through imread/imwrite or some other tool.

有些工具可能会有所帮助:

There are some tools that might be helpful:

我更喜欢矢量图形,因此在需要透明度时使用svg导出.如果确实有位图,请使用 imwrite(bitmapData,'a.png','png','transparency',backgroundColor).

I prefer vector graphics, so use svg exports when transparency is needed. If indeed you have a bitmap, use imwrite(bitmapData, 'a.png', 'png', 'transparency', backgroundColor).

这篇关于如何使用透明背景保存图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆