-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparsing_by_config.m
73 lines (25 loc) · 1.07 KB
/
parsing_by_config.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
%% parse the color images by config file
clear; close all; clc
if ~isdir('parsing-images/')
mkdir('parsing-images');
end
im_num = length(dir('color-tex-distort/*.png'));
parfor i = 1 : im_num
if mod(i, 5000) == 0
i
end
%hsvim = hsvread(strcat('color-tex-images\', num2str(i), '.bmp'));
hsvim = rgb2hsv(imread(strcat('color-tex-distort/', num2str(i), '.png')));
if ~isdir(strcat('parsing-images/', num2str(i), '/'))
mkdir(strcat('parsing-images/', num2str(i)));
end
config_info = load(strcat('tex_config/tex_', num2str(i), '.config'));
for j = 1 : size(config_info, 1)
hval = config_info(j, 2);
symbol = num2str(config_info(j, 1));
labelmap = (abs(hsvim(:, :, 1) - hval) < 0.006 & hsvim(:, :, 2) > 0); % s channel to avoid white background
if sum(labelmap(:)) > 0
imwrite(labelmap, strcat('parsing-images/', num2str(i), '/', symbol, '.png'), 'png');
end
end
end