var previousGrayImageDataList = []; 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; // alert('called for bodyRegionId: ' + $scope.MaskImageSRC[x].bodyRegionId); var bodyRegionId = maskCanvasData[x].bodyRegionId; var canvasId = maskCanvasData[x].canvasId; var maskData = maskCanvasData[x].maskData; var coloredImageDataVar1 = coloredImageCanvasList[bodyRegionId - 1]; var grayImageDataVar1 = grayImageDataList[bodyRegionId - 1]; var coloredImageDataVar = coloredImageDataVar1.data; var grayImageDataVar = grayImageDataVar1.data; var counter = 0; var imageDataVar = maskData.data; // var previousBRID; var counter = 0; var n = maskData.data.length; for (var z = 0; z < TermList.length; z++) { if (previousGrayImageDataList[bodyRegionId - 1] != null) { grayImageDataVar1 = previousGrayImageDataList[bodyRegionId - 1]; grayImageDataVar = grayImageDataVar1.data; } for (var i = 0; i < n; i += 4) { var RED = imageDataVar[i] - 9; var GREEN = imageDataVar[i + 1] - 9; var BLUE = imageDataVar[i + 2] - 9; var Red; var Green; var Blue; var zero = "0"; if ((RED).toString().length != 2) { Red = zero.concat((RED).toString()) } else { Red = (RED).toString() } if ((GREEN).toString().length != 2) { Green = zero.concat((GREEN).toString()) } else { Green = (GREEN).toString() } if ((BLUE).toString().length != 2) { Blue = zero.concat((BLUE).toString()) } else { Blue = (BLUE).toString() } var Icolor = (Red + Green + Blue); // alert('Icolor: ' + Icolor) if (parseInt(TermList[z]._TermNumber) == parseInt(Icolor)) { counter++; matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i }); matched = true; var RED_coloredImage = coloredImageDataVar[i]; grayImageDataVar[i] = RED_coloredImage; var GREEN_coloredImage = coloredImageDataVar[i + 1]; grayImageDataVar[i + 1] = GREEN_coloredImage; var BLUE_coloredImage = coloredImageDataVar[i + 2]; grayImageDataVar[i + 2] = BLUE_coloredImage; var ALPHA_coloredImage = coloredImageDataVar[i + 3]; grayImageDataVar[i + 3] = ALPHA_coloredImage; } } previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageDataVar1; } if (matched == true) { self.postMessage({ 'bodyRegionId': bodyRegionId, 'value': grayImageDataVar1, }); } } } self.onmessage = function (e) { getLocationForMatchedTermsInWholeBody(e.data.termList, e.data.maskCanvasData, e.data.coloredImageCanvasList, e.data.coloredImageMRCanvasList, e.data.grayImageDataList, e.data.grayImageMRDataList); } function launchMatchPixelWorkerProcess() { var worker = new Worker('match-pixel-wp.js'); worker.onmessage = function (e) { var pixelLocation = e.data.msg; self.postMessage({ 'msg': pixelLocation }); }; worker.onerror = function (e) { alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); }; }