From: Bruno on
Hello,

consider this:

Iseg = getframe(ImageHandle);
imwrite(Iseg.cdata, [dialog.outputPath dialog.outputFilename '.png']);

ImageHandle is a handle to a figure ready to be saved, all calculations were done.
It was done with 'Visible' off, so all the drawings were not shown.
But when getframe( ) runs, the image appears in a figure window.

How to write the image associated to ImageHandle without showing it
in a Matlab figure?
or
How to use getframe( ) quietly, that is, not showing anything on the screen?
or
How to use imwrite directly with the handle? How could one obtain an indexed image
or an array to use with imwrite, from the ImageHandle?

Marchesi.
From: Matthew Whitaker on
"Bruno " <bruno.marchesi(a)gmail.com> wrote in message <hks05g$4g1$1(a)fred.mathworks.com>...
> Hello,
>
> consider this:
>
> Iseg = getframe(ImageHandle);
> imwrite(Iseg.cdata, [dialog.outputPath dialog.outputFilename '.png']);
>
> ImageHandle is a handle to a figure ready to be saved, all calculations were done.
> It was done with 'Visible' off, so all the drawings were not shown.
> But when getframe( ) runs, the image appears in a figure window.
>
> How to write the image associated to ImageHandle without showing it
> in a Matlab figure?
> or
> How to use getframe( ) quietly, that is, not showing anything on the screen?
> or
> How to use imwrite directly with the handle? How could one obtain an indexed image
> or an array to use with imwrite, from the ImageHandle?
>
> Marchesi.

Have you considred using the print command to save it.

imageHandle = figure('Visible','off');
axesHdl = axes('parent', imageHandle);
plot(axesHdl,sin(0:0.1:2*pi))
dialog.outputPath = cd;
dialog.outputFilename = 'test';
ext = '.png';
print(['-f',int2str(imageHandle)],'-dpng',fullfile(dialog.outputPath,[dialog.outputFilename,ext]))

Hope this helps
Matt W
From: Bruno on
Hello Matt,

your code worked like a charm, isolated and applied to my project as well. Thank you.

There's still an elf around here, though. Before the print( ), there's this plot( ):

plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 1)

Well, it has always worked. Now, all the line colors still do, *except* white, which
turns black. That is, when you see it onscreen, it's white. In the file, it's black. I've tried all of them: red, green, blue, etc, they all print as they should. Even black is printed as black.

Don't mean to be picky, but we need that white guy.

Any spell I could cast here??

Marchesi
From: Steven Lord on

"Bruno " <bruno.marchesi(a)gmail.com> wrote in message
news:hku4sr$94h$1(a)fred.mathworks.com...
> Hello Matt,
>
> your code worked like a charm, isolated and applied to my project as well.
> Thank you.
>
> There's still an elf around here, though. Before the print( ), there's
> this plot( ):
>
> plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 1)
>
> Well, it has always worked. Now, all the line colors still do, *except*
> white, which
> turns black. That is, when you see it onscreen, it's white. In the file,
> it's black. I've tried all of them: red, green, blue, etc, they all print
> as they should. Even black is printed as black.
>
> Don't mean to be picky, but we need that white guy.
>
> Any spell I could cast here??

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/figure_props.html#InvertHardcopy

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Bruno on
It worked. Thank you.

was:

print(['-f',int2str(handleImage)],'-dpng',...
[dialog.outputPath dialog.outputFilename '.png'])

is:

set(handleImage,'InvertHardcopy','off');
print(['-f',int2str(handleImage)],'-dpng',...
[dialog.outputPath dialog.outputFilename '.png'])

Prints to file white, black and other line colors ok (as they were in the figure).

Marchesi