Read dataset file name only
조회 수: 1 (최근 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!