1 | % read the raw images, their masks and their labels: |
---|
2 | dpath='/Volumes/mm/PRLab/Data/icpr2012_continued/data/Main_Dataset/'; |
---|
3 | N = 28; |
---|
4 | |
---|
5 | X = cell(1,1); |
---|
6 | k=0; |
---|
7 | for i=1:N |
---|
8 | i |
---|
9 | % first read the label file |
---|
10 | dinfo = importdata(sprintf('%s/Images/%02d/%02d.csv',dpath,i,i)); |
---|
11 | dat = dinfo.textdata(2:end,:); |
---|
12 | %cellid = str2num(cell2mat(dat(:,2))); |
---|
13 | cellid = str2num(strvcat(dat(:,2))); |
---|
14 | pattlab = dat(:,6); |
---|
15 | % then read the images |
---|
16 | fnames = dir(sprintf('%s/Cells/Cell_Images/%02d/*.png',dpath,i)); |
---|
17 | M = size(fnames,1); |
---|
18 | for j=1:M |
---|
19 | k = k+1; |
---|
20 | nr = str2num(fnames(j).name(1:3)); |
---|
21 | fullfname = sprintf('%s/Cells/Cell_Images/%02d/%s',dpath,i,fnames(j).name); |
---|
22 | X{k,1} = importdata(fullfname); |
---|
23 | fullfname = sprintf('%s/Cells/Cell_Masks/%02d/%s',dpath,i,fnames(j).name); |
---|
24 | bigmask = importdata(fullfname); |
---|
25 | X{k,2} = (bigmask(dinfo.data(nr,2):dinfo.data(nr,4)-1,... |
---|
26 | dinfo.data(nr,1):dinfo.data(nr,3)-1) > 0); |
---|
27 | X{k,3} = i; |
---|
28 | X{k,4} = pattlab(nr,:); |
---|
29 | X{k,5} = nr; |
---|
30 | |
---|
31 | end |
---|
32 | end |
---|
33 | |
---|
34 | |
---|
35 | Itrain = [ 1 2 3 5 6 7 8 9 11 14 18 20 25 26]; |
---|
36 | Itest = [ 4 10 12 13 15 16 17 19 21 22 23 24 27 28]; |
---|
37 | I = cell2mat(X(:,3)); |
---|
38 | j = []; |
---|
39 | for i=1:length(Itrain) |
---|
40 | j = [j; find(I==Itrain(i))]; |
---|
41 | end |
---|
42 | x = X(j,:); |
---|
43 | j = []; |
---|
44 | for i=1:length(Itest) |
---|
45 | j = [j; find(I==Itest(i))]; |
---|
46 | end |
---|
47 | z = X(j,:); |
---|
48 | save cells x z; |
---|
49 | |
---|