![]() |
MATLAB-将图像写入eps文件
在MATLAB中,如何将矩阵写入[URL="http://en.wikipedia.org/wiki/Encapsulated_PostScript"]EPS[/URL]格式的图像中?
似乎imwrite不支持EPS。 转换在我使用的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) ; 但是我得到了: [INDENT] ???使用==> imshow在191时出错 IMSHOW需要Java才能运行。 ==> study_weaker在122时出错 imshow(img,'border','tight',...%#在图形窗口中显示,不包含 191错误(eid,'%s需要Java才能运行。',upper(mfilename)); [/INDENT]我该如何解决? [B]回答:[/B] 一种可能的解决方案是使用[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/images/imshow.html"]IMSHOW[/URL]绘制图像,然后使用[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/print.html"]PRINT[/URL]将整个图形打印为.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 该解决方案的一个缺点是,如果图像太大而无法容纳在屏幕上,则[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/images/imshow.html"]IMSHOW[/URL]会将其缩小以适合屏幕,这会降低图像在屏幕上的分辨率。但是,您可以使用[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f3-84337.html#f3-99727"]PRINT函数[/URL]的[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f3-84337.html#f3-99727"]-r选项[/URL]调整保存图像的最终分辨率。例如,通过执行以下操作,可以将图形打印为分辨率为300 dpi的封装的2级彩色PostScript。 print('new_image.eps','-depsc2','-r300'); [B]编辑:[/B]如果您无法使用[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/images/imshow.html"]IMSHOW[/URL] (或者因为您没有[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/images/"]图像处理工具箱,[/URL]或者因为您使用的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 您也可以查看[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/print.html#brasey_"]此文档,[/URL]以了解没有显示器的打印方式。 [url=https://stackoverflow.com/questions/2478633]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 02:22。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.