<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265134</link>
    <title>MATLAB Central Newsreader - Poor quality when saving figures as images</title>
    <description>Feed for thread: Poor quality when saving figures as images</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 06 Nov 2009 02:16:03 -0500</pubDate>
      <title>Poor quality when saving figures as images</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265134#692573</link>
      <author>Brad </author>
      <description>I have a routine that processes some data and creates figures as it goes, and I want to know how to programatically save the figures as images, and get the exact same results as I would get via the File &amp;gt; Save As... menu dialog from the figure window.&lt;br&gt;
&lt;br&gt;
Currently, if I save a figure through the File &amp;gt; Save As... menu, I'm happy with the way it looks (just like it looks on screen).  But if I try to programatically save the same figures using saveas or print like below, they look bad in my opinion.  I lose the background color I specified, the aspect ratio isn't what I specified, the font size is huge, etc.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
saveas(gcf,path,'png');   &lt;br&gt;
-OR-&lt;br&gt;
print(gcf,'-dpng',path);&lt;br&gt;
&lt;br&gt;
How can I avoid the ugly &quot;default&quot; look and get the same results as when manually saving via the menu?&lt;br&gt;
&lt;br&gt;
Thanks!</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 03:39:02 -0500</pubDate>
      <title>Re: Poor quality when saving figures as images</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265134#692583</link>
      <author>Oliver Woodford</author>
      <description>&quot;Brad &quot; &amp;lt;wooleverbradj@johndeere.com&amp;gt; wrote in message &amp;lt;hd00t3$o98$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have a routine that processes some data and creates figures as it goes, and I want to know how to programatically save the figures as images, and get the exact same results as I would get via the File &amp;gt; Save As... menu dialog from the figure window.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Currently, if I save a figure through the File &amp;gt; Save As... menu, I'm happy with the way it looks (just like it looks on screen).  But if I try to programatically save the same figures using saveas or print like below, they look bad in my opinion.  I lose the background color I specified, the aspect ratio isn't what I specified, the font size is huge, etc.&lt;br&gt;
&amp;gt;      &lt;br&gt;
&amp;gt; saveas(gcf,path,'png');   &lt;br&gt;
&amp;gt; -OR-&lt;br&gt;
&amp;gt; print(gcf,'-dpng',path);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; How can I avoid the ugly &quot;default&quot; look and get the same results as when manually saving via the menu?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&lt;br&gt;
Hi&lt;br&gt;
&lt;br&gt;
I don't know about the same as the Save as.. option, but export_fig generates an image of a figure as it appears on screen. You find it at:&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
HTH,&lt;br&gt;
Oliver</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 11:10:55 -0500</pubDate>
      <title>Re: Poor quality when saving figures as images</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265134#692648</link>
      <author>roger</author>
      <description>On Nov 6, 3:16&#160;am, &quot;Brad &quot; &amp;lt;wooleverbr...@johndeere.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; I have a routine that processes some data and creates figures as it goes, and I want to know how to programatically save the figures as images, and get the exact same results as I would get via the File &amp;gt; Save As... menu dialog from the figure window.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Currently, if I save a figure through the File &amp;gt; Save As... menu, I'm happy with the way it looks (just like it looks on screen). &#160;But if I try to programatically save the same figures using saveas or print like below, they look bad in my opinion. &#160;I lose the background color I specified, the aspect ratio isn't what I specified, the font size is huge, etc.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; saveas(gcf,path,'png'); &#160;&lt;br&gt;
&amp;gt; -OR-&lt;br&gt;
&amp;gt; print(gcf,'-dpng',path);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; How can I avoid the ugly &quot;default&quot; look and get the same results as when manually saving via the menu?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&lt;br&gt;
try playing with the papertype, papersize, paperposition etc.&lt;br&gt;
properties of the figure, these will allow you to control the size of&lt;br&gt;
the printed image. There is a print option that lets you choose&lt;br&gt;
whether to include the background colors or not, i forgot what it is&lt;br&gt;
called but it should be in the print documentation.</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 18:13:02 -0500</pubDate>
      <title>Re: Poor quality when saving figures as images</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265134#692738</link>
      <author>Brad </author>
      <description>&quot;Oliver Woodford&quot; &amp;lt;o.j.woodford.98@cantab.net&amp;gt; wrote in message &amp;lt;hd05om$j3k$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Brad &quot; &amp;lt;wooleverbradj@johndeere.com&amp;gt; wrote in message &amp;lt;hd00t3$o98$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I have a routine that processes some data and creates figures as it goes, and I want to know how to programatically save the figures as images, and get the exact same results as I would get via the File &amp;gt; Save As... menu dialog from the figure window.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Currently, if I save a figure through the File &amp;gt; Save As... menu, I'm happy with the way it looks (just like it looks on screen).  But if I try to programatically save the same figures using saveas or print like below, they look bad in my opinion.  I lose the background color I specified, the aspect ratio isn't what I specified, the font size is huge, etc.&lt;br&gt;
&amp;gt; &amp;gt;      &lt;br&gt;
&amp;gt; &amp;gt; saveas(gcf,path,'png');   &lt;br&gt;
&amp;gt; &amp;gt; -OR-&lt;br&gt;
&amp;gt; &amp;gt; print(gcf,'-dpng',path);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; How can I avoid the ugly &quot;default&quot; look and get the same results as when manually saving via the menu?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I don't know about the same as the Save as.. option, but export_fig generates an image of a figure as it appears on screen. You find it at:&lt;br&gt;
&amp;gt; &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; HTH,&lt;br&gt;
&amp;gt; Oliver&lt;br&gt;
&lt;br&gt;
Thanks!  This is doing pretty much exactly what I wanted.</description>
    </item>
    <item>
      <pubDate>Thu, 10 Jun 2010 02:37:05 -0400</pubDate>
      <title>Re: Poor quality when saving figures as images</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265134#753177</link>
      <author>Jkarretero Jkarretero</author>
      <description>I have written a function that does what you are asking for:&lt;br&gt;
&lt;br&gt;
imageSize is a vector of 2 values indicating width &amp; height.&lt;br&gt;
fileName and imageSize are optionals.&lt;br&gt;
&lt;br&gt;
function saveImage (figureHandle, fileName, imageSize)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ~exist('fileName','var'), fileName='image.png'; end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if exist('imageSize','var')&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% Adjust figure to size required&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(figureHandle, 'Position', [1 100 imageSize(1) imageSize(2)]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% Convert figure to image&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(figureHandle, 'Visible', 'on');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;frame = getframe(figureHandle);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(figureHandle,'Visible','off');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imagen = frame.cdata;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% Save the image to disk&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imwrite(imagen, fileName);&lt;br&gt;
end</description>
    </item>
  </channel>
</rss>

