-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcreateTXT.m
52 lines (35 loc) · 1.12 KB
/
createTXT.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
49
50
51
52
list = dir('imgs2/*.tif');
n = 10;
a = 800;
rng('default')
labels = [repmat(0, 8*n, 1)
repmat(1, 9*n, 1)
repmat(2, 6*n, 1)
repmat(3, 5*n, 1)
repmat(4, 8*n, 1)];
fileID = fopen('CRACKS.txt','w');
fprintf(fileID, '%d\n',length(list)*n);
for i = 1:length(list)
skel = imread([list(i).folder '\' list(i).name]);
for j = 1:n
colLim = size(skel,2) - a;
rowLim = size(skel,1) - a;
c = ceil(rand * colLim);
r = ceil(rand * rowLim);
patch = skel(r:r+a-1, c:c+a-1, :);
if round(rand)
patch = flip(patch, 1);
end
if round(rand)
patch = flip(patch, 2);
end
[~,links, nodes] = extractStats(patch);
fprintf(fileID, '%d %d\n',length(nodes), labels((i-1)*n+j));
for k = 1:length(nodes)
fprintf(fileID,'0 ');
fprintf(fileID,'%d ', length(nodes(k).conn), nodes(k).conn-1);
fprintf(fileID,'\n');
end
end
end
fclose(fileID);