Read dataset file name only
6 次查看(过去 30 天)
显示 更早的评论
Hello, i want to ask how i want my code can read dataset folder name only like the folder name like 0,1,2,3,4,5
Right now i can only read image name only. So, i want the system can read and call dataset folder name.
Here my code
SelectFile.m
%N = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
function d = SelectFile(A,N)
M = 6; % number of class [0 to 5 ]
cnt(1:M)=0; % counter for each class
% get all filenames in the data directory
D = dir(A);
% extract only N file
d =D(1:N);
% see the statistic of each class pattern
for i=1:N
fn = D(i).asl_dataset; %file name
x = fn(38); % extract target from filename
%find the distribution of file being extracted per class
if (x == '0')
cnt(1)=cnt(1)+1;
elseif (x=='1')
cnt(2)=cnt(2)+1;
elseif (x=='2')
cnt(3)=cnt(3)+1;
elseif (x=='3')
cnt(4)=cnt(4)+1;
elseif (x=='4')
cnt(5)=cnt(5)+1;
elseif (x=='5')
cnt(6)=cnt(6)+1;
end
end
cnt
bar([0 1 2 3 4 5],cnt);
title('statistic number of pattern per class');
text(0:5,cnt,num2str(cnt'),'vert','bottom','horiz','center');
end
sample.m
D = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
d1 = SelectFile(D,360);
[Dat,Trgt] = FExtraction(d1);
net = NNTrain(Dat,Trgt);
%Test NN using Test Patterns
%D = 'C:\RESEARCH\pattern\fingers\test\*.png';
D = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
d2 = SelectFile(D,60);
[Data,Target] = FExtraction(d2);
O = NNTest(net,Data,Target);
disp('recognition rate is : ');
disp(O);
0 个评论
采纳的回答
Walter Roberson
2022-1-9
D = 'C:\Users\USER\Documents\MATLAB\Project\asl_dataset\asl_dataset';
dinfo = dir(D);
dinfo(ismember({dinfo.name}, {'.', '..'})) = []; %remove . and ..
dinfo(~[dinfo.isdir]) = []; %remove any files leaving only directories
foldernames = {dinfo.name};
2 个评论
Walter Roberson
2022-1-9
"So, i want the system can read and call dataset folder name."
It does that part only. It looked to me as if you only wanted to know the names of the folders that were present.
Perhaps you have a different need. Perhaps you want to know, for each file, which folder it came from? That is possible
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!