how to save image in specific folder in matlab?

288 ビュー (過去 30 日間)
Awais Khan
Awais Khan 2019 年 11 月 29 日
編集済み: Rahul punk 2021 年 6 月 3 日
Hi, Actually i am trying to read image in matlab and then applying specific operation like enhancing, contrasting etc then i want to save the new image after operation in a specific folder, but i am facing problem in saving image in matlab, i am trying to code which is shown below but it gives error, kindly help me anyone who known the solution
code.png.

回答 (3 件)

Image Analyst
Image Analyst 2019 年 11 月 29 日
First of all you need to define ImageFolder, which you have not done. So assign it to some folder on your drives and that will fix that.
Next you need to give a base file name (a string) to full file, NOT an image array.
Or try this snippet:
% 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, '*.png');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
imwrite(img, fullFileName);

Ankit
Ankit 2019 年 12 月 3 日
Moved from comment section to Answer!!!
--------------------------------------------------------
ImageFolder need to be a string.
for e.g.
img = 'img.png'
ImageFolder = 'D:/Matlab Coding of Projects';
fullFileName = fullfile(ImageFolder,img)
Another recommendation would be using uiputfile
[baseFileName, ImageFolder] = uiputfile(); % To get the name of the file that the user wants to save!
fullFileName = fullfile(ImageFolder, baseFileName)
imwrite(yourImage, fullFileName);

Rahul punk
Rahul punk 2021 年 6 月 2 日
編集済み: Rahul punk 2021 年 6 月 3 日
%read image
tt= imshow(image) ;
%save your image other location with any name save desktop or any folder also
saveas(tt,'C:\Users\admin\Desktop\testimagesave.jpg') ;
  1 件のコメント
Rik
Rik 2021 年 6 月 2 日
The original question is more about defining the path dynamically, while your code defines it statically.

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

カテゴリ

Help Center および File ExchangeDisplay Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by