var UpdatedGrayImageDataList = []; var doneBRID = []; var abc = 'hello'; 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")) console.log('imagredata= ' + grayImageData) var matchedRGBLocationInBodyRegion = []; var matched; console.log(grayImageData) var n = maskCanvasData.data.length; var maskData = maskCanvasData.data; for (var z = 0; z < termList.length; z++) { 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 < n; i += 4) { var RED = maskData[i] - 9; var GREEN = maskData[i + 1] - 9; var BLUE = maskData[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)) { // debugger; // 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; } } // debugger; previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageData; // if (matched == true) { // } 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); }