将精确的图像输出保存在MATLAB中 [英] Save exact image output from imagesc in matlab

查看:160
本文介绍了将精确的图像输出保存在MATLAB中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想保存由imagesc(magic(3))(确切的彩虹表示形式)生成的图像,有可能吗?

Hi , I want to save this image produced from imagesc(magic(3)), the exact rainbow representation, is it possible?

谢谢.

这个问题可能看起来像一个重复的问题,但事实并非如此.我在此站点上研究了类似问题的解决方案,但并不令我满意. 我已经查看了Matlab帮助中心,得到的答案很简单,就是 http://goo的底部. gl/p907wR

This question might look like a duplicate , but it is not . I looked at the solution to the similar question at this site , but it did not satisfy me . I have looked into the Matlab help center and the close answer that I got was this one , at the bottom of http://goo.gl/p907wR

推荐答案

要将图形保存为文件(与创建方式无关),应该执行以下操作:

To save the figure as a file (don't matter how it was created), one should do:

saveas(figureHandle,'filename','format')

其中FigureHandle可能是gcf句柄,这意味着:获取当前图形.

where figureHandle could be the gcf handle, which means: get current figure.

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

As pointed in the discussion, if someone doesn't want the ticks to be shown, the person can add:

set(gca,'XTick',[])
set(gca,'YTick',[])

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

where gca is the handle to the current axis, just as gcf. If you have more than one axis, don't forget to "handle the handles". They are returned to you when you create them, i.e.:

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

其中对值是使用以下语法声明的图形或轴属性:

where the pair value are the figure or axes properties declared in the following syntax:

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

以下是有关轴属性,以及有关

Here are the matlab documentation about the Figure and Axes Properties, and about the saveas method.

示例:

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

The image saved with the following code:

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')

这篇关于将精确的图像输出保存在MATLAB中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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