MATLAB - 将图像写入eps文件 [英] MATLAB - write image into an eps file

查看:480
本文介绍了MATLAB - 将图像写入eps文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MATLAB中,如何在 EPS 格式的图像中编写矩阵?

In MATLAB, how do you write a matrix into an image of EPS format?

似乎 imwrite 不支持EPS。

转换在我正在使用的Linux服务器上不起作用:

Convert is not working on the Linux server I am using:

$ convert exploss_stumps.jpg exploss_stumps.eps
convert: missing an image filename `exploss_stumps.eps' @ convert.c/ConvertImageCommand/2838

为什么?

我在终端模式下尝试了gnovice的想法:

I tried gnovice's idea under terminal mode:

    figH = figure('visible','off') ;
imshow(img,'border','tight',...      %# Display in a figure window without
        'InitialMagnification',100);  %#    a border at full magnification
print(strcat(filepath,'/', dataset,'_feature_',num2str(j), '.eps'),'-depsc2');
    close(figH) ;

但是我得到了:


???使用==> imshow时出错191在
IMSHOW需要运行Java。



错误==> study_weaker at 122

imshow(img,'border','tight',...%#Display在数字窗口中没有b $ b $
191错误(eid,'%s需要Java运行。',upper(mfilename));

??? Error using ==> imshow at 191
IMSHOW requires Java to run.

Error in ==> study_weaker at 122
imshow(img,'border','tight',... %# Display in a figure window without

191 error(eid,'%s requires Java to run.',upper(mfilename));

我该如何解决?

推荐答案

一种可能的解决方案是使用 IMSHOW 绘制图像。 ,然后使用 PRINT将整个图形打印为.eps

One possible solution is to plot your image using IMSHOW, then print the entire figure as a .eps using PRINT:

img = imread('peppers.png');         %# A sample image
imshow(img,'Border','tight',...      %# Display in a figure window without
       'InitialMagnification',100);  %#    a border at full magnification
print('new_image.eps','-deps');      %# Print the figure as a B&W eps

此解决方案的一个缺点是,如果图像太大,无法放在屏幕上, IMSHOW 将缩小它以适应,这将降低图像的屏幕分辨率。但是,您可以使用 -r< number> PRINT功能的选项。例如,您可以通过执行以下操作将图形打印为分辨率为2 dpi的Encapsulated Level 2 Color PostScript:

One drawback to this solution is that if the image is too big to fit on the screen, IMSHOW will shrink it to fit, which will reduce the on-screen resolution of the image. However, you can adjust the final resolution of the saved image using the -r<number> option for the PRINT function. For example, you can print your figure as an Encapsulated Level 2 Color PostScript with a resolution of 300 dpi by doing the following:

print('new_image.eps','-depsc2','-r300');

编辑:如果您无法使用 IMSHOW (要么是因为你没有图像处理工具箱或因为您使用的是不允许它的MATLAB模式,这是创建和打印图形的另一种方法:

If you are unable to use IMSHOW (either because you don't have the Image Processing Toolbox or because you are using a MATLAB mode that doesn't allow it), here is an alternative way to create and print the figure:

img = imread('peppers.png');      %# A sample image
imagesc(img);                     %# Plot the image
set(gca,'Units','normalized',...  %# Set some axes properties
        'Position',[0 0 1 1],...
        'Visible','off');
set(gcf,'Units','pixels',...      %# Set some figure properties
        'Position',[100 100 size(img,2) size(img,1)]);
print(gcf,'new_image.eps','-depsc2','-r300');  %# Print the figure

您还可以查看本文档,了解如何在没有显示的情况下进行打印。

You can also take a look at this documentation to see how printing works without a display.

这篇关于MATLAB - 将图像写入eps文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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