how to save multiple images in .mat file using matlab software.
古いコメントを表示
i want code to be such that it takes 5 images and save in 1 .mat file.
回答 (3 件)
Walter Roberson
2016 年 1 月 25 日
0 投票
Image Analyst
2016 年 1 月 25 日
Try save():
save(fullMatFileName, 'image1', 'image2', 'image3', 'image4', 'image5');
where the imagen are the variable names of the different image arrays in your program.
4 件のコメント
shikhar srivastava
2016 年 1 月 25 日
Image Analyst
2016 年 1 月 25 日
That pretty much is the full code. I didn't create the variables because you have done that. I'm assuming you have the 5 variables you want to save already. Of course you didn't supply your code so I don't know how you created them (for example with imread) or what they're called but you MUST know that. The only other thing is to decide on a filename for your .mat file, but I'm assuming you know how to do that. If not, try something a bit fancy, like 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 % Or "pwd" or wherever you want.
defaultFileName = fullfile(startingFolder, '*.mat');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullMatFileName = fullfile(folder, baseFileName)
shikhar srivastava
2016 年 1 月 25 日
Image Analyst
2016 年 1 月 25 日
What does that mean. To get it, you simply click and drag your mouse over it, then copy it and paste it into an editor window.
mona
2017 年 2 月 3 日
0 投票
After creat .mat file with images,I need to deal with index of .mat file
4 件のコメント
Image Analyst
2017 年 2 月 3 日
I don't know what that means. What index? You have a .mat file with a known filename, and it contains 5 variables with known names, so what index are you talking about?
mona
2017 年 2 月 7 日
a .mat file contains more than 5 variables ,it contains 50 variables with known name,but I neeed to make for loop to load variables in a .mat file?
Jan
2017 年 2 月 7 日
You can load the mat file at once and use the loop to access the loaded contents.
Image Analyst
2017 年 2 月 7 日
No, you don't need a loop. If you call load() without accepting the result into a structure,
load(filename);
it just "poofs" the variables into the workspace with their actual original name. No loop needed.
If you accept into a structure like
s = load(filename);
The 50 variables will be fields/members of the s structure. Then you can use the fieldnames() function for get the variable names.
カテゴリ
ヘルプ センター および File Exchange で Images についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!