代码之家  ›  专栏  ›  技术社区  ›  Tim unnamed eng

matlab-将图像写入EPS文件

  •  7
  • Tim unnamed eng  · 技术社区  · 15 年前

    在matlab中,如何将矩阵写入 EPS 格式?

    似乎 imwrite 不支持EPS。

    Convert在我使用的Linux服务器上不工作:

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

    为什么?


    我在终端模式下尝试了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) ;
    

    然而,我得到:

    ????使用时出错=>imshow at 191
    IMSee要求Java运行。

    在=>研究中出错在122时变弱
    imshow(img,“border”,“tight”,……%#在图形窗口中显示

    191错误(EID,'%s需要Java运行),上(MFiNeNAME);

    我怎么修?

    3 回复  |  直到 8 年前
        1
  •  7
  •   gnovice    15 年前

    一种可能的解决方案是使用 IMSHOW ,然后使用 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
    

    这个解决方案的一个缺点是,如果图像太大而无法在屏幕上显示, 伊姆斯 将缩小到合适的大小,这将降低图像的屏幕分辨率。但是,可以使用 -r<number> option for the PRINT function . 例如,通过执行以下操作,可以将图形打印为分辨率为300 dpi的封装2级彩色PostScript:

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

    编辑: 如果您无法使用 伊姆斯 (或者因为你没有 Image Processing Toolbox 或者因为您使用的是不允许使用的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
    

    你也可以看看 this documentation 看不到显示器的打印效果。

        2
  •  0
  •   Peter Mortensen icecrime    13 年前

    应该可以使用imwrite。不过,你必须添加一个彩色地图才能工作。

    但是,检查帮助页面,我发现不可能使用imwrite来编写EPS文件。

        3
  •  0
  •   RAHUL SINGHAL    8 年前

    下面的代码可以帮助您将PNG文件转换为EPS。

    fileName = 'FarmerStats'; % your FILE NAME as string
    
    A = imread(fileName,'png');
    set(gcf,'visible','off') %suppress figure
    image(A);                
    axis image               % resolution based on image
    axis off                 % avoid printing axis 
    set(gca,'LooseInset',get(gca,'TightInset')); % removing extra white space in figure
    saveas(gcf,fileName,'epsc');   % save as COLOR eps file
    
    推荐文章