MATLAB: How to save image using Guide GUI

guiguideimwriteoutput

I'm trying to save an image in a TIFF format by opening a dialog box and choosing the location and the name.I know the below code opens dialog box but nothing will happen when I click save.
[FileName,PathName]= uiputfile('*.tiff','Save Workspace As');
How do I save my images?

Best Answer

uiputfile() simply gets a filename. You still have to call imwrite() to to the actual writing to disk. Try this:
% Get the name of the file that the user wants to save.
% Note, if you're saving an image you can use imsave() instead of uiputfile().
startingFolder = userpath
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
imwrite(yourImageArray, fullFileName);
Related Question