0

如果我使用 saveas 命令将多个绘图保存为图像,我该如何显示它们。我正在使用的代码是:

if we==1
    figure()
    saveas(gcf(),'myownfile.jpg'); % save the figure if condition is satisfied  
    clf % clear the figure after saving it
end

如果 we==1 则程序检查条件,然后在保存绘图后清除图形。它是功能的一部分。而在函数中保存为图像的图必须显示在主函数中。代码是:

p=imread('myownfile.jpg');% read the image
imshow(p); %show the image

但我得到一个空白的数字。我不知道为什么?

4

3 回答 3

0

可能是()你在你的代码之后gcf可能会导致一些问题。

固定代码:

if we==1
    figure()
    saveas(gcf,'myownfile.jpg'); % save the figure if condition is satisfied  
    clf % clear the figure after saving it
end
于 2012-05-19T11:47:19.177 回答
0

我总是使用该print命令,因为它可以为您提供更多控制权。

print(gcf, '-djpeg', '-r400', 'myownfile.jpg')

如果我不得不猜测您遇到的问题,我敢打赌您需要将其称为:saveas(gcf,'myownfile.jpg','jpg'); 因为 Matlab 在这方面可能非常愚蠢。

另一个可能的问题是渲染器(使用get/set(gcf,'Renderer')) - 其中一些无法保存。

于 2012-05-19T15:51:30.373 回答
0

这是解决方案。感谢您的帮助。通过删除命令figure()并在上面的代码中添加命令saveas(gcf(),strcat('myownpic',strcat(int2str(m1),'.jpg')));将解决问题。

于 2012-05-23T14:04:27.243 回答