saving an image in a specific folder
28 views (last 30 days)
i'm trying to save an image to a specific folder, however when i save the image i would like to give it any name i want.
similar to saving a word document, and a dialogue box pops up and asks you where would you like the destination folder and the name of the file
More Answers (2)
Image Analyst on 17 May 2018
You can use imsave():
img = imread('peppers.png');
imshow(img); % Display image
[filename, user_canceled] = imsave();
Or else the longer way with uiputfile():
% 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 % Or "pwd" or wherever you want.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
fullFileName = fullfile(folder, baseFileName)