How to export non-blurry eps images?

后端 未结 10 1805
攒了一身酷
攒了一身酷 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:30

    Apply opengl renderer to the figure

    figure(gcf);
    set(gcf,'renderer','opengl');
    
    0 讨论(0)
  • 2020-12-15 07:36

    This page helped me a lot: http://tech.mof-mof.co.jp/blog/machine-learning-octave.html (written in Japanese, please use google translate for it)

    And this is also helpful: Octave-Gnuplot-AquaTerm error: set terminal aqua enhanced title "Figure 1"...unknown terminal type"

    I also answered at https://www.coursera.org/learn/machine-learning/discussions/weeks/2/threads/Dh-aRfqSEeaHSQ6l4xnh6g.

    I reinstalled gnuplot like this:

    $ brew cask install xquartz
    $ brew cask install aquaterm
    $ brew uninstall gnuplot
    $ brew install gnuplot --with-aquaterm --with-x11 --with-qt  # you can show other options by `$ brew options gnuplot`
    

    You may edit ~/.octaverc like this:

    setenv("GNUTERM", "qt")
    

    and in octave window, after typing "system gnuplot", then

    set pm3d interpolate 2, 2
    

    After saving the file, open octave-cli.app, and type

    imagesc(magic(3)), colorbar
    

    I got this.

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

    The blurring actually depends on the rendering software your viewer application or printer uses. To get good results all the time, make each pixel in your image an 8x8 block of pixels of the same color, i.e. resize the image like this:

    im2 = imresize(im1, 8, 'nearest');
    

    The blurring then only affects the pixels at the edge of each block. 8x8 blocks are best as they compress without nasty artifacts using DCT compression (sometimes used in eps files).

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

    I've been long struggling with this problem as well. So far, GSView is the only viewer I've found that displays the eps figures produced by Matlab (R2015b) correctly. eps2eps did not work for me (psutils 1.23). The following eventually worked for me:

    1. Export the figure to pdf, following the instructions here
    2. pdf2ps file.pdf file.eps
    0 讨论(0)
  • 2020-12-15 07:48

    At first I thought you were doing something incorrectly, but then I remembered that this was an issue that was bothering the hell out of me a year or so ago. I couldn't come up with a way to "fix" this behaviour and from what I've researched, this is most likely a bug and several others have had this problem too and there is no known solution. Of course, I could be wrong about the last part and there might be solutions out there that have come out since I looked for them.

    Any way, my workaround this problem was to use pcolor with shading flat instead of imagesc. When you export this to an eps format it preserves the image correctly. Example:

    pcolor(rand(20));
    shading flat
    print('-depsc','figure.eps')
    

    enter image description here

    NOTE: You might see the appearance of thin, faint white lines along the anti-diagonals of each little square (depends on the OS & viewer). These are the edges of the graphics primitives that are used to render the image. However, this is not a flaw in MATLAB's export, but rather a fault in rendering in your EPS/PDF viewer. For e.g., with the default settings in Preview on my mac, these lines show up, whereas with the default in Adobe Reader 9.4, they don't appear.

    0 讨论(0)
  • If anyone is still interested in a workaround: Open the .eps-file with text editor and search for "interpolate". You'll probably find "/Interpolate true def" two or three times. Replace "true" with "false" and be happy :)

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