一种可能的解决方案是使用
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
这种解决方案的一个缺点是,如果图像太大而无法放在屏幕上,IMSHOW会将其缩小以适应,这将降低图像的屏幕分辨率.但是,您可以使用-r option for the PRINT function调整保存图像的最终分辨率.例如,您可以通过执行以下操作将图形打印为分辨率为300 dpi的Encapsulated Level 2 Color PostScript:
print('new_image.eps','-depsc2','-r300');
编辑:如果您不能使用IMSHOW(或者因为您没有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,了解如何在没有显示器的情况下进行打印.