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); } var blueNum = termnumber.substring(4, 6); if (blueNum == BLUE) { GREEN = GREEN.toString(); if (GREEN.length != 2) { GREEN = zero.concat(GREEN); } var greenNum = termnumber.substring(2, 4); if (greenNum == GREEN) { RED = RED.toString(); if (RED.length != 2) { RED = zero.concat(RED); } var redNum = termnumber.substring(0, 2); if (redNum == RED) { for (var index = i; index < i + nextStep; index += 1) { grayImageDataVar[index] = coloredImageDataVar[index]; } //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; } } 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); }