Saving GUI plot to bitmap file without displaying Matlab figure

Hi all. I have a question. I'm creating code for my company in Matlab (simulation tool), which generates data that can be visualized by e.g. contourf. This data should not be accessible to the end user. Since Matlab figures allow access to all data through the 'get' command, I have to go around making bitmap file directly instead of a figure file.
There is a twist, however, as I am using two GUI's. The main GUI opens a second GUI where the figures are plotted on according to the layout made with GUIDE. So in principle, I want the figure of the secondary GUI to be plotted directly as a bitmap. What would be the easiest way of doing this?

6 件のコメント

Walter Roberson
Walter Roberson 2011 年 10 月 10 日
Using "print" or "getframe" without having the figure displayed is fairly tricky, and the documented mechanisms tend to fail on some platform or another. Using the file exchange contribution export_fig might _help_, but I do not know if anyone has solved the problem completely.
Tobias Elmøe
Tobias Elmøe 2011 年 10 月 11 日
I cannot get the GUI to print any of its UIcontrols if the plot is not made visible. Only if I force the plot to show up on screen I can show the UIcontrols I want.
The more I think about it, the harder it seems to hide my data. Even as pcode, the user can apply dbstop and dbstep in to find the moment at which the figure is created (it will take a long time to find out, but it should be possible). Then, using the 'get' command and the figure handle, the user can extract the children handle and eventually get X,Y and Z data out.
Instead, I am thinking if creating a MEX file that calls mexEval to perform the required operations. In this way all functions can be called without allowing the user to dbstep his way in before I can delete the figure data again. Any comments on that solution?
Robert Cumming
Robert Cumming 2011 年 10 月 11 日
why do you need to show the UI Contols? Does the plot (and title/legend/labels not provide enough information?)
Tobias Elmøe
Tobias Elmøe 2011 年 10 月 11 日
That's correct. It does not.
Robert Cumming
Robert Cumming 2011 年 10 月 12 日
a possible solution then is to move the GUI off the screen and then toggle the visibility on then off on consecitive lines - its not elegent but it works...
Note: you only need to do this once at the start - any updates to uicontrols will be captured...
Tobias Elmøe
Tobias Elmøe 2011 年 10 月 18 日
Good solution! That would work. Thanks! (I cannot select accept this answer, as it is written in the comments field, sorry).

サインインしてコメントする。

回答 (4 件)

Robert Cumming
Robert Cumming 2011 年 10 月 11 日

1 投票

I have a similar application in it I create postscript files using
print ( GUIHANDLE, '-dpsc', 'TEMP_PS_FILE.ps', '-append', '-loose' )
(Note: this can be done with figure hidden), then I convery this PS file to a PDF file using
On PC: ps2pdf
On LINUX: use LINUX ghostscript.
The reason I picked PS was for vector graphics -> therefore you dont get "fuzzy" pictures or end up with really big files. Ofcourse the actual data iremains invisible to the end user.
FYI: I run this as a compiled exe with no GUI shown to the user. It is controlled/customised by the user through a control file (it runs in batch)
Grzegorz Knor
Grzegorz Knor 2011 年 10 月 10 日

0 投票

e.g.:
h = figure('Visible','off');
plot(1:10)
print(h,'-dbmp','example')
close(h)
Malcolm Lidierth
Malcolm Lidierth 2011 年 10 月 11 日

0 投票

You could draw the figure using Java. The FEX has several examples using JFreeChart. The pic below shows one using a standard MATLAB example and the Project Waterloo Graphics Library - but that is not yet ready for distro I am afraid.

2 件のコメント

karan
karan 2011 年 11 月 24 日
how did u upload an image at matlab answers????
Walter Roberson
Walter Roberson 2011 年 11 月 24 日
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

サインインしてコメントする。

Daniel Shub
Daniel Shub 2011 年 10 月 18 日

0 投票

"Since Matlab figures allow access to all data through the 'get' command, I have to go around making bitmap file directly instead of a figure file."
You could of course either compile your entire application or just compile the portion of the application that generates the bitmap.
I would bet that you could still extract the data from figures with visibility turned off that are only displayed for 1 line. Off the top of my head I would think that overloading the print command would make this pretty easy.

カテゴリ

ヘルプ センター および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

タグ

質問済み:

2011 年 10 月 10 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by