imwrite or print

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

imwrite or print

Octave - General mailing list
Hello,

after

t = linspace(0,2*pi,100)';
plot(t,sin(t));
tic;print -dpng "-S560,420" fig_print.png;toc
tic;imwrite(getframe(gcf).cdata,"fig_imwrite.png");toc

I could not find any differences between both files (fig_print.png and fig_imwrite.png).

However imwrite is much faster than print

So, I have a few general questions about both commands

1) Is imwrite always faster than print ?

2) Is there any situation where one command should be used instead of the other one?

3) Is there any situation where the results will be different?

Kind regards,
Leonardo


Reply | Threaded
Open this post in threaded view
|

Re: imwrite or print

Francesco Potortì
>t = linspace(0,2*pi,100)';
>plot(t,sin(t));
>tic;print -dpng "-S560,420" fig_print.png;toc
>tic;imwrite(getframe(gcf).cdata,"fig_imwrite.png");toc
>
>I could not find any differences between both files (fig_print.png and fig_imwrite.png).

From the getframe definition:
     Without an argument, capture the current axes excluding ticklabels,
     title, and x/y/zlabels.  The returned structure FRAME has a field

So once you add (for example) a title you should see the difference.

>However imwrite is much faster than print

That's interesting and may be useful when saving many images.

>1) Is imwrite always faster than print ?

Probably: print does much more

>2) Is there any situation where one command should be used instead of the other one?

print is for general use, imwrite only creates bitmap files from a
single plot with the above limitations

--
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(gate 20, 1st floor, room C71)         Web:    http://fly.isti.cnr.it