Uiputfile problem - how do i tell callback which file I want it to save?
Afficher commentaires plus anciens
I have a GUI (made with GUIDE) that processes images and returns an output to a result axes (result-axes). I now want to get the user to save this resultant file using uiputfile. The code I am using is
[filename,pathname] = uiputfile('*.mat','Save As...');
What code do I add now to point the program to the result_axes and export the file that now appears there so that the user can save it? I'm guessing its something to do with (gcf, handles.result_axes) but apart from that I am not sure.
Any help would be most welcome Sue x
Réponses (1)
Fangjun Jiang
le 21 Juil 2011
Assume you have your processed image data in a variable called ImageData (I am creating some data to explain it). The following will save the data to an .mat file.
ImageData=magic(100);
save(fullfile(pathname,filename),'ImageData');
10 commentaires
Sue
le 21 Juil 2011
Sue
le 21 Juil 2011
Fangjun Jiang
le 21 Juil 2011
You are doing image processing and then show the image in an axes. Do you want to save the processed image data, or do you want to save the figure showing the image?
Fangjun Jiang
le 21 Juil 2011
Okay, maybe your uiputfile() should already give the hint. I assume you want to save the data. See the updated answer.
Sue
le 21 Juil 2011
Fangjun Jiang
le 21 Juil 2011
Well, you are almost there. You've found the uiputfile() which allows you to let user pick a file. The command to save the data to a .mat file is save(). You just need to find the data next.
Sue
le 21 Juil 2011
Fangjun Jiang
le 21 Juil 2011
It's better to dig into the M code to find the data. If not, you might be able to get the data from the axes. It may depend on what figure do you have. e.g.
handle=image(magic(10));
ImageData=get(handle,'CData');
Sue
le 21 Juil 2011
Fangjun Jiang
le 22 Juil 2011
Okay, you want to save the data, right? The best way is to find that original data in the code and use save() command to save it. If you can't find it but you have the handle of the image figure, you could get the data from the image figure and then save it. magic() function is to create some data as an example, image(magic(10)) puts it in a figure. Next line is to get the data. If you have the handle if your axes, why don't you try: ImageData=get(handles.result_axes,'CData')
Catégories
En savoir plus sur Develop Apps Programmatically dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!