how do i read a folder database into matlab

2 ビュー (過去 30 日間)
basma alshaibah
basma alshaibah 2019 年 4 月 5 日
編集済み: Rik 2019 年 4 月 9 日
i have a database as a folder and in that folder there are sub folders each with a number of photos of a person walking photographed from different angles, to be used for gait recognition.
how do i read that folder into matlab?
im new a matlab and i have this code to read an image but i want it to be used for reading a folder, is there anyway to do that ?
[fname, path]=uigetfile('.png','Open an Image as input for training');
fname=strcat(path, fname);
im=imread(fname);
im=im2bw(im);
imshow(im);
title('Input Image');
c=input('Enter the Class(Number from 1-12)');

採用された回答

Rik
Rik 2019 年 4 月 5 日
Use uigetdir to ask the user for a folder, then use dir to get the list of files inside that folder, then use a for loop to load the images in a loop.
  2 件のコメント
basma alshaibah
basma alshaibah 2019 年 4 月 5 日
編集済み: Rik 2019 年 4 月 9 日
i used uigetdir and it worked but dir didn't. am i using it correctly?
selpath = uigetdir('C:\Users\Basma\Desktop','open a file for input')
dir selpath
and can you please show me how to iterate over the images in each subfolder?
because i tried a nested for loop but it didn't work
files = uigetdir('C:\Users\Basma\Desktop','open a file for input')
for i = 1 : 1: numel(files)
for j = 1 : 1 : numel(files(i))
x = imread(i,j);
end
end
thank you in advance
Rik
Rik 2019 年 4 月 6 日
Read the documentation for the two functions. Matlab documentation is very good and contains several examples.

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

その他の回答 (1 件)

TED jenson
TED jenson 2019 年 4 月 5 日

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by