var UpdatedGrayImageDataList = []; var doneBRID = []; var abc = 'hello'; getLocationForMatchedTermsInWholeBody = function (termList, maskCanvasData, coloredImageCanvasList, coloredImageMRCanvasList, grayImageDataList, grayImageMRDataList) { var matchedRGBLocationInBodyRegion = []; var matched; for (var x = 0; x < maskCanvasData.length; x++) { matched = false; 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]; console.log('canvasId =' + canvasId) //if (canvasId.match('_MR')) { // coloredImageDataVar = coloredImageMRCanvasList[bodyRegionId]; // grayImageDataVar = grayImageMRDataList[bodyRegionId]; //} //else { coloredImageDataVar = coloredImageCanvasList[bodyRegionId - 1]; grayImageDataVar = grayImageDataList[bodyRegionId-1]; //} console.log('grayImageDataVar= ' + grayImageDataVar) 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, 'canvasId': canvasId }); machLocationWP.onmessage = function (e) { doneBRID.push(e.data.bodyRegionId); var canvasID = (e.data.canvasId).replace('_mci', ''); UpdatedGrayImageDataList.push({ 'canvasID': canvasID, 'imageData': e.data.value }); //UpdatedGrayImageDataList[e.data.bodyRegionId] = e.data.value if (doneBRID.length==9) { self.postMessage({ 'value': UpdatedGrayImageDataList, }) } }; 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); }