I\'m exporting an image in Matlab using the eps format, but it smooths the image. Matlab does not blur the image using other formats such as png. I would like to know how to
A note regarding Yoda's answer: in Preview in Mac OS X, you can make the thin white diagonal lines across each of the squares disappear by unchecking "Anti-alias text and screen art". Of course, the downside is that then any text (e.g. figure axes, etc) is not anti-aliased. Unfortunately, unchecking that has no effect on blurriness if you're using imagesc.
Another note is that if you use preview to make a pdf from your eps, the resulting pdf still displays correctly (non-blurry) when you open it in Acrobat.
I just wrote this simple drop-in replacement for imagesc
. It doesn't support all but the most basic features, but I still hope it helps.
function h = imagesc4pdf(C)
[ny nx] = size(C);
px = bsxfun(@plus, [-0.5; 0.5; 0.5; -0.5], reshape(1:nx, [1 1 nx]));
py = bsxfun(@plus, [-0.5; -0.5; 0.5; 0.5], 1:ny);
n = numel(C);
px = reshape(repmat(px, [1 ny 1]), 4, n);
py = reshape(repmat(py, [1 1 nx]), 4, n);
h = patch(px, py, reshape(C,1,n), 'linestyle', 'none');
xlim([.5 nx+.5]);
ylim([.5 ny+.5]);
set(gca, 'ydir', 'reverse');
not sure why it works but you can try doing the following:
eps2eps oldfile newfile
does the trick for me (on a mac os)
The problem is reproducible on a Mac, and the issue is with the eps renderer rather than MATLAB. For e.g., saving imagesc(rand(20))
and viewing with Preview and GSview results in the following:
Clearly, the information is not lost. It is just not interpreted/read correctly by some EPS viewers. The solution is simple: use GSview to view your eps
images. You can download it from here
On Macs especially, if your end application is latex/pdflatex, you will have to explicitly set it to use GS/GSview, because otherwise, it will default to the Quartz engine, which is baked into the OS.
I am unable to reproduce the behavior your described. Here is the code I used, tested using R2010b on WinXP 32-bit:
M = fspecial('gaussian',[20 20],5);
imagesc(M)
print('-dpng','a.png')
print('-depsc2','b.eps')
Perhaps this is an issue with your EPS viewer...