I have jpg images which I generated in my GUI. Furthermore, I want to save them in a Database.mat file along with a name i.e. in a two dimensional array having rows as names and a column of images. I am not getting through how to create the database.mat file and insert images in it as I have less proficiency in Matlab. Please help me as it is the part of my thesis. Thanks in advance!

 採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 8 日

0 投票

Use a table() data structure if you want to index by row names. For example,
dinfo = dir('*.tif');
T = table();
for K = 1 : length(dinfo)
filename = dinfo(K).name;
filecontent = imread(filename);
T{filename,1} = filecontent;
end
T.Properties.VariableNames{1} = 'ImageContent';

7 件のコメント

Ria3242
Ria3242 2015 年 9 月 10 日
編集済み: Ria3242 2015 年 9 月 10 日
okay.
So the filname is got through dinfo and stored as row in T and you are calling the filecontent as the image right?
Sir, I want to store usernames(rows) along with their image passwords (column values) for a GUA system. Is it possible that I get username from the edit handle and store it into the table row?
Walter Roberson
Walter Roberson 2015 年 9 月 10 日
Yes the filecontent is the image. I was avoiding using a variable named "image" because image() is a key MATLAB routine for displaying images.
Yes you can get a string from an edit box and store it in the table row, but if you are proceeding one at a time and you need the user to respond for each one, consider using inputdlg()
Easier, though, would be to name the files according to the username, as you do not need to prompt the user for each one. The small change you could make would be to change
T{filename,1} = filecontent;
into
[~, username, ~] = fileparts(filename);
T{username,1} = filecontent;
Ria3242
Ria3242 2015 年 10 月 7 日
Hello Sir, I typed
dinfo = dir('*.jpg');
T = table();
in command window, but it says this error:
Undefined function or variable 'table'.
Why so?
Walter Roberson
Walter Roberson 2015 年 10 月 7 日
Are you possibly using a version of MATLAB before R2013b ?
If you are, then what version are you using, and do you have the Statistics Toolbox?
Ria3242
Ria3242 2015 年 10 月 8 日
Im using Matlab 7.0.4
Yes I have the statistics Toolbox.
Walter Roberson
Walter Roberson 2015 年 10 月 8 日
Statistics has the similar Dataset Array -- though I do not know if it existed that far back.
Ria3242
Ria3242 2015 年 10 月 15 日
okay Sir. I'll surely try it. Thank you so much for your help!

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

その他の回答 (0 件)

カテゴリ

質問済み:

2015 年 9 月 8 日

コメント済み:

2015 年 10 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by