extract-wp.js
3.16 KB
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
previousGrayImageDataList = [];
getLocationForMatchedTermsInWholeBody = function (termList, maskCanvasData, coloredImageData, grayImageData, bodyRegionId, canvasId) {
console.log('for bodyRegionId: ' + bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"))
var masklen = maskCanvasData.data.length;
var maskData = maskCanvasData.data;
var nextStep=4;
var zero = "0";
for (var z = 0; z < termList.length; z++) {
var termnumber=termList[z]._TermNumber;
if(termnumber.length<6)
{
continue;
}
if (previousGrayImageDataList[parseInt(bodyRegionId - 1)] != null) {
grayImageData = previousGrayImageDataList[parseInt(bodyRegionId - 1)];
}
if (grayImageData != null) {
var grayImageDataVar = grayImageData.data;
var coloredImageDataVar = coloredImageData.data;
for (var i = 0; i < masklen; i += nextStep) {
var RED = maskData[i] - 9;
if (RED <0) { continue; }
var GREEN = maskData[i + 1] - 9;
if (GREEN <0) { continue; }
var BLUE = maskData[i + 2] - 9;
if (BLUE <0) { continue; }
BLUE=BLUE.toString();
if (BLUE.length !=2)
{
BLUE = zero.concat(BLUE);
}
if(termnumber.startsWith(BLUE,4)) {
GREEN=GREEN.toString();
if (GREEN.length !=2)
{
GREEN = zero.concat(GREEN);
}
if(termnumber.startsWith(GREEN,2)) {
RED=RED.toString();
if (RED.length !=2)
{
RED = zero.concat(RED);
}
if(termnumber.startsWith(RED,0)) {
var Icolor = (RED + GREEN + BLUE);
if (termnumber == Icolor) {
for (var index = i; index < i+nextStep; index += 1) {
grayImageDataVar[index]=coloredImageDataVar[index];
}
}
}
else{continue;}
}
else{continue;}
}
else{continue;}
}
// debugger;
previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageData;
}
}
self.postMessage({
'bodyRegionId': bodyRegionId,
'value': grayImageData,
'canvasId': canvasId
});
}
self.onmessage = function (e) {
getLocationForMatchedTermsInWholeBody(e.data.termList, e.data.maskCanvasData, e.data.coloredImageData,
e.data.grayImageData, e.data.bodyRegionId, e.data.canvasId);
}