How to export non-blurry eps images?

后端 未结 10 1806
攒了一身酷
攒了一身酷 2020-12-15 07:08

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

相关标签:
10条回答
  • 2020-12-15 07:48

    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.

    0 讨论(0)
  • 2020-12-15 07:48

    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');
    
    0 讨论(0)
  • 2020-12-15 07:50

    not sure why it works but you can try doing the following:

    eps2eps oldfile newfile
    

    does the trick for me (on a mac os)

    0 讨论(0)
  • 2020-12-15 07:57

    UPDATE:

    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:

    Preview screenshot

    enter image description here

    GSview screenshot

    enter image description here

    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.


    PREVIOUS ANSWER:

    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')
    

    a.png

    a.png

    b.eps

    b.eps

    Perhaps this is an issue with your EPS viewer...

    0 讨论(0)
提交回复
热议问题