how to save multiple images with different names?

26 ビュー (過去 30 日間)
romasha
romasha 2014 年 2 月 4 日
コメント済み: Image Analyst 2014 年 2 月 5 日
hi, In my gui i take an image as a user input and do some processes over it like cropping , normalization and feature extraction now i want feature extracted image to be saved in matlab folder i write code but it saves only one image whereas i want every image like user select image from folder and after processed this image feature extracted image got save and then when user re run the gui and select another image then this feature extracted image save with another name i've tried this.... Code
subplot(pics,columns,subplt); featureEx=imshow(temp{i1});
filename = sprintf('FeatureExtrctd_image%d.bmp', i1);
imwrite(featureEx,filename,'bmp');
title('Feature Extracted image');
subplt=subplt+1;
...............
where i1=1 cause user only select one image at a time so there is no need for iterations
  1 件のコメント
Walter Roberson
Walter Roberson 2014 年 2 月 5 日
Could you explain further what you mean by "every image like user select image from folder" ?

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

回答 (2 件)

Amit
Amit 2014 年 2 月 5 日
編集済み: Amit 2014 年 2 月 5 日
I think one way to do this will by using an identifier taken from the original file name. Otherwise
filename = sprintf('FeatureExtrctd_image%d.bmp', i1);
will always try to save as FeatureExtrctd ......
Lets say your file name is 'myfile.jpg'
[~,X_filename,~] = fileparts('myfile.jpg'); % user selected file
filename = sprintf('FeatureExtrctd_image%d.bmp', i1);
filename_new = [X_filename '_' filename];

Image Analyst
Image Analyst 2014 年 2 月 5 日
You can do that with trivial modifications to the code in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Let us know if you can't figure it out and we'll help. If you want the user to select an image at every iteration, you'll have to put this code into the loop:
% 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.
break;
end
fullFileName = fullfile(folder, baseFileName)
  2 件のコメント
romasha
romasha 2014 年 2 月 5 日
when i launch my gui it take image from user and doing cropping, normalization and feature extraction on that image i want feature extracted image to be save like when i run my gui for the first time feature extracted image get save then gui get exit and when i run my gui for the second time it save feature extracted image with another name as on second time i select different image so feartur extracted image is different from first hope u'll understand
Image Analyst
Image Analyst 2014 年 2 月 5 日
Not exactly sure, but I think using uigetfile and uiputfile are what you need.

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

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by