在matlab中保存imagesc的精确图像输出

mot*_*iur 7 matlab matlab-figure

彩虹

嗨,我想保存这个产生的图像imagesc(magic(3)),确切的彩虹表示,是否可能?

谢谢.

这个问题可能看似重复,但事实并非如此.我在这个网站上查看了类似问题的解决方案,但它并不能让我满意.我已经查看了Matlab帮助中心,我得到的答案就是这个,在http://goo.gl/p907wR的底部

Wer*_*ner 14

要将图形保存为文件(无论如何创建),应该:

saveas(figureHandle,'filename','format')
Run Code Online (Sandbox Code Playgroud)

其中figureHandle可以是gcf句柄,这意味着:获取当前数字.

如讨论中所指出的,如果有人不希望显示刻度,则该人可以添加:

set(gca,'XTick',[])
set(gca,'YTick',[])
Run Code Online (Sandbox Code Playgroud)

其中gca是当前轴的句柄,就像gcf.如果您有多个轴,请不要忘记"处理手柄".它们会在您创建它们时返回给您,即:

hFig = figure(pairValuedProperties); % Create and get the figure handle
hAxes1 = suplot(2,1,1,pairValuedProperties); % Create and get the upper axes handle
hAxes2 = suplot(2,1,2,pairValuedProperties); % Create and get the bottom axes handle
Run Code Online (Sandbox Code Playgroud)

其中pair值是以下语法声明的figure或axes属性:

'PropertyName1',PropertyValue1,'PropertyName2',PropertyValue2,…

以下是有关轴属性的matlab文档,以及有关saveas方法的文档.


例:

使用以下代码保存的图像:

figure 
imagesc(magic(3))
set(gca,'XTick',[]) % Remove the ticks in the x axis!
set(gca,'YTick',[]) % Remove the ticks in the y axis
set(gca,'Position',[0 0 1 1]) % Make the axes occupy the hole figure
saveas(gcf,'Figure','png')
Run Code Online (Sandbox Code Playgroud)

没有白色边框的图

  • 我的图像也有白色边框。要删除它,使轴占据孔图:`set(gca,'Position',[0 0 1 1])` (2认同)
  • 哈哈,你只是无情,最后我很高兴。 (2认同)