Hello,
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

 採用された回答

Stephen23
Stephen23 2018 年 5 月 17 日
編集済み: Stephen23 2018 年 5 月 17 日

0 投票

Use uiputfile to get the file name and path, e.g. where I is your image array:
[F,P] = uiputfile();
imwrite(I,fullfile(P,F))

8 件のコメント

hasan alhussaini
hasan alhussaini 2018 年 5 月 17 日
would you be able to elaborate? i can't seem to get it to work
Stephen23
Stephen23 2018 年 5 月 17 日
@hasan alhussaini: my answer contains a complete working example. If you are having problems please show the code that you tried.
hasan alhussaini
hasan alhussaini 2018 年 5 月 17 日
it works perfectly thank you!
hasan alhussaini
hasan alhussaini 2018 年 5 月 17 日
just one last question. i get the error "Unable to determine the file format from the file name". therefore i added imwrite(I,fullfile(P,F),'tif')
i can save the image now. but i can't open it again... what am i doing wrong?
Stephen23
Stephen23 2018 年 5 月 17 日
"i can save the image now. but i can't open it again... what am i doing wrong?"
How are you trying to open the image? With what application? Please show the output of this command:
whos I
where I is your image array. If possible please upload the image file by clicking the paperclip button.
hasan alhussaini
hasan alhussaini 2018 年 5 月 17 日
this is the code i'm using. sinog_2 is the variablei'm trying to save
[F,P] = uiputfile(); %this code saves the sinogram imwrite(sinog_2,fullfile(P,F),'tif')
(i managed to save the file by clicking on the variable in the work space and clicking "save as", however i'm trying to achieve this simultaneously by coding)
Image Analyst
Image Analyst 2018 年 5 月 17 日
Try this fix
if ~contains(F, '.tif', 'IgnoreCase', true)
% User did not enter the .tif extension. add it for them.
F = [F, '.tif']; % Append .tif
end
fullFileName = fullfile(P, F);
imwrite(I, fullFileName);
hasan alhussaini
hasan alhussaini 2018 年 5 月 17 日
it works perfectly! thank you ^^

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

その他の回答 (2 件)

Image Analyst
Image Analyst 2018 年 5 月 17 日

0 投票

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.
return;
end
fullFileName = fullfile(folder, baseFileName)
imwrite(yourImage, fullFileName);
akshatha nayak
akshatha nayak 2019 年 4 月 23 日

0 投票

How to take real world image of person eye and store it in mysql database and use that image for comparing with other image ?

1 件のコメント

Image Analyst
Image Analyst 2019 年 4 月 23 日
Start a new question with this, and BE SURE to add the database tag, and DatabaseToolbox product when you post it.

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

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by