|
a |
|
b/matlab/gen_dataset2.m |
|
|
1 |
clear |
|
|
2 |
close all |
|
|
3 |
tic |
|
|
4 |
% path to folder containing training data |
|
|
5 |
old_trainset_folder = '/home/andrew/mitosis/MITOS/training/'; |
|
|
6 |
map_folder = '/home/andrew/mitosis/maps/'; |
|
|
7 |
|
|
|
8 |
% make training set directories |
|
|
9 |
new_trainset_folder = '/home/andrew/mitosis/mitosis-train-large/false/'; |
|
|
10 |
if exist(new_trainset_folder, 'dir') |
|
|
11 |
rmdir(new_trainset_folder, 's') |
|
|
12 |
end |
|
|
13 |
mkdir(new_trainset_folder) |
|
|
14 |
|
|
|
15 |
% count the total number of images for the waitbar |
|
|
16 |
N = 0; |
|
|
17 |
for j=1:5 |
|
|
18 |
% find the number of images in the folder |
|
|
19 |
folder = [old_trainset_folder 'A' num2str(j-1, '%02u') '_v2/']; |
|
|
20 |
n = length(dir([folder '*.csv'])); |
|
|
21 |
N = N + n; |
|
|
22 |
end |
|
|
23 |
|
|
|
24 |
% iterate over the twelve patients |
|
|
25 |
M = 0; |
|
|
26 |
P = 0; |
|
|
27 |
k = 0; |
|
|
28 |
h = waitbar(0,'Creating training set ... 0 %'); |
|
|
29 |
for j=1:5 |
|
|
30 |
% find the number of images in the folder |
|
|
31 |
folder = [old_trainset_folder 'A' num2str(j-1, '%02u') '_v2/']; |
|
|
32 |
image_files = dir([folder '*.bmp']); |
|
|
33 |
csv_files = dir([folder '*.csv']); |
|
|
34 |
n = length(image_files); |
|
|
35 |
|
|
|
36 |
% create new data set |
|
|
37 |
for i=1:n |
|
|
38 |
image_file = [folder image_files(i).name]; |
|
|
39 |
csv_file = [folder csv_files(i).name]; |
|
|
40 |
[pathstr,name,ext] = fileparts(image_file); |
|
|
41 |
map_file = [map_folder name '.png']; |
|
|
42 |
[m, p] = add_dataset2(image_file, csv_file, new_trainset_folder, map_file); |
|
|
43 |
M = M + m; |
|
|
44 |
P = P + p; |
|
|
45 |
k = k + 1; |
|
|
46 |
waitbar(k/N,h,['Creating training set ... ' num2str(100*k/N) ' %']); |
|
|
47 |
end |
|
|
48 |
end |
|
|
49 |
|
|
|
50 |
close(h) |
|
|
51 |
toc |
|
|
52 |
disp(['Created ' num2str(P) ' window training images from ' num2str(N) ' large training images containing ' num2str(M) ' mitotic figures.']) |