-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_20_20_test.m
48 lines (40 loc) · 1.72 KB
/
make_20_20_test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
clear all
close all
clc
mkdir('for_20_20_test');
for i = 1:15
mkdir(sprintf('for_20_20_test//test_7_%d',i));
mkdir(sprintf('for_20_20_test//test_7_%d//imgs',i));
mkdir(sprintf('for_20_20_test//test_7_%d//labels',i));
fold = dir(sprintf('user_adaptive_mine_77_corr//test_7_%d//labels',i));
for j = 3 : size(fold,1)
label_pix = imread(sprintf('user_adaptive_mine_77_corr//test_7_%d//labels//%s',i,fold(j).name));
if sum(label_pix(:,1)) > 255
break;
end
end
nf_rand = randperm(j-4,20)+3; %random select 20 in nf
f_rand = randperm(size(fold,1)-j, 20) + j;
img_path = sprintf('user_adaptive_mine_77_corr//test_7_%d//imgs',i);
label_path = sprintf('user_adaptive_mine_77_corr//test_7_%d//labels',i);
dest_path = sprintf('for_20_20_test//test_7_%d//imgs',i);
dest_path_label = sprintf('for_20_20_test//test_7_%d//labels',i);
sourcedir = dir(img_path);
sourcedir_label = dir(label_path);
for ii = nf_rand
sourcefile = fullfile(img_path, sourcedir(ii).name);
destfile = fullfile(dest_path, sourcedir(ii).name);
copyfile(sourcefile,destfile);
sourcefile = fullfile(label_path, sourcedir_label(ii).name);
destfile = fullfile(dest_path_label, sourcedir_label(ii).name);
copyfile(sourcefile,destfile);
end
for ii = f_rand
sourcefile = fullfile(img_path, sourcedir(ii).name);
destfile = fullfile(dest_path, sourcedir(ii).name);
copyfile(sourcefile,destfile);
sourcefile = fullfile(label_path, sourcedir_label(ii).name);
destfile = fullfile(dest_path_label, sourcedir_label(ii).name);
copyfile(sourcefile,destfile);
end
end