How to save image using Guide GUI?

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?

 Respuesta aceptada

Image Analyst
Image Analyst el 2 de Mayo de 2015
Editada: Image Analyst el 2 de Mayo de 2015
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);

5 comentarios

Marge Tok
Marge Tok el 2 de Mayo de 2015
So I'm guessing 'Specify a file' means which image I want to save? What is yourImageArray and '*.*'?
Image Analyst
Image Analyst el 2 de Mayo de 2015
You can put whatever prompt you like. If you don't like "Specify a file" you can choose "Browse to the folder you want and type in the name you want the image to take once it is saved on your drive" - or whatever you want.
What did you call your variable that has the image you want to save? Use that name instead of yourImageArray.
Marge Tok
Marge Tok el 2 de Mayo de 2015
Awesome, Thank you!
soukaina elqamch
soukaina elqamch el 14 de Mayo de 2019
I still don't understand the yourimagearray and specify a file part, can you please explain it to me and where can i find them (I really need this for a project)
Image Analyst
Image Analyst el 14 de Mayo de 2019
You have an image in your program, right? Well, what is the name of the variable that you used? Whatever it is, replace yourImageArray with the actual name of your variable. It's not yourImageArray (the name I chose) - it's whatever name you chose to give to your image variable, like the return value from imread() when you called that to read your image in from disk.
As far as how uiputfile() works, just read the documentation.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Mayo de 2015

Comentada:

el 14 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by