【问题标题】:How can I change figure edges of a figure created with imshow?如何更改使用 imshow 创建的图形的图形边缘?
【发布时间】:2019-04-02 05:24:07
【问题描述】:
我正在使用imshow 创建这个二进制图像。当它显示该图时,我看到一个灰色背景,图中没有边缘。如果我将绘图保存为.png,我会看到背景为白色,并且看不到图中的任何边缘。如何在该图中添加边?
图片如imshow:
图像保存为 PNG:
【问题讨论】:
标签:
matlab
figure
imshow
edges
【解决方案1】:
默认情况下,保存的图形具有白色背景。通过将图窗的InvertHardcopy 属性设置为'off',确保保存图窗的颜色与显示屏上的颜色匹配。
例子:
A = rand(300, 300) > 0.1;
f = figure();
f.InvertHardcopy = 'off';
imshow(A);
title('Binary Image threshold 0.9');
saveas(f, 'test.png');
给予:
或者,可以在imshow 中设置轴的可见性并使刻度为空:
A = rand(300, 300) > 0.1;
f = figure();
iptsetpref('ImshowAxesVisible', 'on');
imshow(A);
xticks({});
yticks({});
title('Binary Image threshold 0.9');
saveas(f, 'test.png');
给出:
来源:Matlab Documentation