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