saving images as a database

3 ビュー (過去 30 日間)
Tony
Tony 2014 年 1 月 12 日
回答済み: Image Analyst 2014 年 1 月 14 日
I am trying to put a folder of jpg images in a database .mat i tried this from similar stuff that i googled, i was successful doing it to one image using
save('test.mat','f')
here is the failed code,
if true
srcFiles = dir('F:\matlab\face\data\*.jpg') % the folder images are in
for i = 1 : length(srcFiles)
filename = imread(['F:\matlab\face\data\',srcFiles(i).jpg]);
holdImage(i) = imread(filename);
end save('testimagebase.mat','holdImage'); end
  1 件のコメント
Tony
Tony 2014 年 1 月 14 日
is there a way to just load everything in a folder regardless of the name of the file

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

採用された回答

Image Analyst
Image Analyst 2014 年 1 月 14 日
Try this snippet. Set folder to:
folder = 'F:\matlab\face\data';
ListOfImageNames = {};
ImageFiles = dir([folder'/*.*']); % Get all files.
for Index = 1:length(ImageFiles)
baseFileName = ImageFiles(Index).name;
[folder, name, extension] = fileparts(baseFileName);
extension = upper(extension);
% Let's save just those we are interested in:
switch lower(extension)
case {'.png', '.bmp', '.jpg', '.tif', '.avi'}
% Allow only PNG, TIF, JPG, or BMP images
ListOfImageNames = [ListOfImageNames baseFileName];
otherwise
end
end
% Now ListOfImageNames is a list of all image format files.
% Now do whatever you want with that list.

その他の回答 (1 件)

Ben
Ben 2014 年 1 月 13 日
Try just this inside your loop:
holdImage(i) = imread(['F:\matlab\face\data\' srcFiles(i)],'jpeg');
  1 件のコメント
Tony
Tony 2014 年 1 月 14 日
is there a way to just load everything in a folder regardless of the name of the file

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

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by