-
Notifications
You must be signed in to change notification settings - Fork 0
/
LORGenerateSimpleAllWeb.m
139 lines (112 loc) · 5.07 KB
/
LORGenerateSimpleAllWeb.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%
% refactored from the SuperParsing code
% im_parser/WebsiteGeneration/MakeWeb.m
% http://www.cs.unc.edu/~jtighe/Papers/ECCV10/index.html
%
function LORGenerateSimpleAllWeb(SPdata,SPparam)
HOMEWEB = fullfile(SPparam.HOMETESTDATA,'Website');
if ~exist(HOMEWEB,'dir'), mkdir(HOMEWEB); end;
HOMESEMANTICLABEL = SPparam.HOMELABELSETS{1}; % HOMELABELSETS{1} = HOMELABELSETS{labelType}; only SemanticLabels
[~,semanticlabelsFolderName] = fileparts(HOMESEMANTICLABEL);
labelColors = GetColors(SPparam.HOMEDATA,SPparam.SPCODE,SPparam.HOMELABELSETS,SPdata.Labels(SPparam.UseLabelSet));
foldList = dir(fullfile(SPparam.HOMETESTDATA,'LearningObjRel',semanticlabelsFolderName,'*'));
for i = length(foldList):-1:1
if strcmp(foldList(i).name,'.') || strcmp(foldList(i).name,'..')
foldList(i) = [];
end;
end;
WebTestList = {foldList.name};
maxDim = 1000;
webIndexFile = fullfile(HOMEWEB,'index.html');
indexFID = fopen(webIndexFile,'w');
fprintf(indexFID,'<!DOCTYPE html>\n');
fprintf(indexFID,'<HTML lang=en xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">\n');
fprintf(indexFID,'<HEAD>\n');
fprintf(indexFID,'<meta http-equiv="content-type" content="text/html; charset=UTF-8">\n');
fprintf(indexFID,'<script type=''text/javascript'' src=''http://code.jquery.com/jquery-1.4.4.min.js''></script>\n\n');
% for checking image size
[folder,onlyName,~] = fileparts(SPdata.testFileList{1});
imLabeled = imread(fullfile(HOMEWEB,semanticlabelsFolderName,WebTestList{1},folder,[onlyName '.png']));
[~,c,~] = size(imLabeled);
fprintf(indexFID,'<STYLE type="text/css">\n');
fprintf(indexFID,'body {\n');
fprintf(indexFID,'\twidth: 100px;\n');
fprintf(indexFID,'}\n');
fprintf(indexFID,'table {\n');
fprintf(indexFID,'\twidth: 500px;\n');
fprintf(indexFID,'}\n');
fprintf(indexFID,'thead tr {\n');
fprintf(indexFID,'\tbackground-color: lightgrey;\n');
fprintf(indexFID,'}\n');
fprintf(indexFID,'.first {\n');
fprintf(indexFID,'\tborder: 1px solid black; vertical-align: top; background-color: white;\n');
fprintf(indexFID,'}\n');
fprintf(indexFID,'#table_container {\n');
fprintf(indexFID,'\tposition:relative;\n');
fprintf(indexFID,'}\n');
fprintf(indexFID,'</STYLE>\n\n');
jsFID = fopen('fixScrollJavascript.js');
tline = fgetl(jsFID);
while ischar(tline)
fprintf(indexFID,tline);
fprintf(indexFID,'\n');
tline = fgetl(jsFID);
end
fclose(jsFID);
fprintf(indexFID,'</HEAD>\n\n');
fprintf(indexFID,'<BODY>\n');
fprintf(indexFID,'<table id="main_table" style="table-layout:fixed; border: 0px solid black;">\n');
fprintf(indexFID,'\t<thead>\n');
fprintf(indexFID,'\t<tr>\n');
fprintf(indexFID,'\t\t<th style="font-size:100%%; width: 200px; background-color: white;">LearingObjRel</th>\n');
fprintf(indexFID,'\t\t<th style="font-size:100%%; width: %dpx;">Original Image</th>\n',c);
for j = 1:length(WebTestList)
fprintf(indexFID,'\t\t<th style="font-size:100%%; width: %dpx;">',c);
if length(WebTestList{j}) > 30
fprintf(indexFID,'%s <br />',WebTestList{j}(1:30));
fprintf(indexFID,'%s',WebTestList{j}(31:end));
else
fprintf(indexFID,'%s',WebTestList{j});
end;
fprintf(indexFID,'</th>\n');
end;
fprintf(indexFID,'\t</tr>\n');
fprintf(indexFID,'\t</thead>\n');
pfig = ProgressBar('Generating Web');
range = 1:length(SPdata.testFileList);
for i = range
fprintf(indexFID,'\t<tr>\n');
im = imread(fullfile(SPparam.HOMEIMAGES,SPdata.testFileList{i}));
[r,~,~] = size(im);
[folder,onlyName,ext] = fileparts(SPdata.testFileList{i});
localImageFile = fullfile(HOMEWEB,'Images',folder,[onlyName ext]);
if ~exist(fileparts(localImageFile),'dir'), mkdir(fileparts(localImageFile)); end;
copyfile(fullfile(SPparam.HOMEIMAGES,SPdata.testFileList{i}),localImageFile,'f');
% name
fprintf(indexFID,'\t\t<td class="first" style="tbackground-color: white;">%s</td>\n',onlyName);
% original image
fprintf(indexFID,'\t\t<td style="width: %dpx;">\n',c);
fprintf(indexFID,'\t\t\t<center><img height="%d" src="%s"></center>\n',min(r,maxDim),['Images/' folder '/' onlyName ext]);
fprintf(indexFID,'\t\t</td>\n');
for j = 1:length(WebTestList)
resultFile = fullfile(SPparam.HOMETESTDATA,'LearningObjRel',semanticlabelsFolderName,WebTestList{j},folder,[onlyName '.mat']);
resultCache = [resultFile '.cache'];
if exist(resultCache,'file')
load(resultCache,'-mat'); % metaData perLabelStat(#labelsx2) perPixelStat([# pix correct, # pix total]);
end;
fprintf(indexFID,'\t\t<td style="font-size:100%%;">\n');
fprintf(indexFID,'\t\t\t<img height="%d" src="%s">\n',min(r,maxDim),[semanticlabelsFolderName '/' WebTestList{j} '/' folder '/' onlyName '.png']);
if exist('perPixelStat','var')
fprintf(indexFID,'<br /><center>%.1f%%</center>\n',100*perPixelStat(1)/perPixelStat(2));
end;
fprintf(indexFID,'\t\t</td>\n');
end;
fprintf(indexFID,'\t</tr>\n');
ProgressBar(pfig,find(range==i),length(range));
end;
close(pfig);
fprintf(indexFID,'</table>\n');
fprintf(indexFID,'</BODY>\n');
fprintf(indexFID,'</HTML>');
fclose(indexFID);
return;