如何更改使用 imshow 创建的图形的图形边缘?

How can I change figure edges of a figure created with imshow?

我正在使用 imshow 创建此二进制图像。当它显示图形时,我看到灰色背景并且图形中没有边缘。如果我将绘图保存为 .png,我会看到背景为白色并且看不到图形的任何边缘。我怎样才能给这个图添加边?

图片如imshow所示:

图像保存为 PNG:

默认情况下,保存的图形具有白色背景。通过将图的 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