term-number-wp.js
3.03 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
var UpdatedGrayImageDataList = [];
var doneBRID = [];
var abc = 'hello';
getLocationForMatchedTermsInWholeBody = function (termList, maskCanvasData, coloredImageCanvasList, coloredImageMRCanvasList, grayImageDataList, grayImageMRDataList) {
// console.log('for termNumer: ' + termNo + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"))
var matchedRGBLocationInBodyRegion = [];
var matched;
for (var x = 0; x < maskCanvasData.length; x++)
{
matched = false;
// alert('called for bodyRegionId: ' + $scope.MaskImageSRC[x].bodyRegionId);
var bodyRegionId = maskCanvasData[x].bodyRegionId;
var canvasId = maskCanvasData[x].canvasId;
var maskData = maskCanvasData[x].maskData;
var coloredImageDataVar= coloredImageCanvasList[bodyRegionId - 1];
var grayImageDataVar = grayImageDataList[bodyRegionId - 1];
//var coloredImageDataVar = coloredImageDataVar1.data;
//var grayImageDataVar = grayImageDataVar1.data;
var counter = 0;
var imageDataVar = maskData.data;
var machLocationWP = new Worker('match-pixel-wp.js');
machLocationWP.postMessage({
'termList': termList,
'maskCanvasData': maskData,
'coloreImageData': coloredImageDataVar,
'grayImageData': grayImageDataVar,
'grayImageMRDataList': grayImageMRDataList,
'bodyRegionId': bodyRegionId
});
machLocationWP.onmessage = function (e) {
console.log('callback: ' + e.data.value+', x='+x);
//var upadteddata = e.data.value;
//var bodyRegionId = e.data.bodyRegionId;
//var grayCanvasID = 'imageCanvas' + bodyRegionId;
//var grayCanvas = document.getElementById(grayCanvasID);
//var grayCanvasContext = grayCanvas.getContext("2d");
//grayCanvasContext.putImageData(upadteddata, 0, 0);
doneBRID.push(e.data.bodyRegionId);
UpdatedGrayImageDataList[e.data.bodyRegionId] = e.data.value
console.log('UpdatedGrayImageDataList: '+ UpdatedGrayImageDataList);
console.log('doneBRID: ' + doneBRID.length);
if (doneBRID.length==9) {
console.log('before sending UpdatedGrayImageDataList= ' + UpdatedGrayImageDataList)
self.postMessage({
'value': UpdatedGrayImageDataList,
'name': 'Happy'
})
}
};
machLocationWP.onerror = function (e) {
console.log('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
};
}
}
self.onmessage = function (e) {
getLocationForMatchedTermsInWholeBody(e.data.termList, e.data.maskCanvasData, e.data.coloredImageCanvasList,
e.data.coloredImageMRCanvasList, e.data.grayImageDataList, e.data.grayImageMRDataList);
}