MATLAB - 将图像写入eps文件

Tim*_*Tim 7 matlab image imagemagick eps

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

似乎imwrite不支持EPS.

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

$ convert exploss_stumps.jpg exploss_stumps.eps
convert: missing an image filename `exploss_stumps.eps' @ convert.c/ConvertImageCommand/2838
Run Code Online (Sandbox Code Playgroud)

为什么?


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

    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) ;
Run Code Online (Sandbox Code Playgroud)

但是我得到了:

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

错误==> study_weaker at 122
imshow(img,'border','tight',...%#在数字窗口中显示没有

191错误(eid,'%s需要Java运行.',upper(mfilename) );

我该如何解决?

gno*_*ice 7

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

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
Run Code Online (Sandbox Code Playgroud)

一个缺点是该解决方案是,如果图像是太大,无法在屏幕上,IMSHOW会缩小以适合,这将减少屏幕分辨率的图像.但是,您可以使用-r<number>PRINT功能选项调整保存图像的最终分辨率.例如,您可以通过执行以下操作将图形打印为分辨率为300 dpi的Encapsulated Level 2 Color PostScript:

print('new_image.eps','-depsc2','-r300');
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

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