diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index f96b30e..a90d90e 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -1385,12 +1385,13 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo .where('bodyRegionId == ' + 1) .select(); var coloredImageData = dataForthisBR.coloredImageData; - var worker = new Worker('term-number-wp.js'); - //for (var i = 0; i < TermList.length; i++) { - + //for (var i = 0; i < TermList.length; i++) { + var worker = new Worker('term-number-wp.js'); + // console.log('Start time taken for term: ' + TermList[i]._TermNumber + 'in posting: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); - worker.postMessage({ + worker.postMessage({ + 'termList': TermList, 'maskCanvasData': $scope.MaskCanvasData, 'coloredImageCanvasList': $rootScope.coloredImageCanvasList, @@ -1400,21 +1401,28 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo }); - //} + //} worker.onmessage = function (e) { - // console.log('callback: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); + console.log('callback: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); - var upadteddata = e.data.value; - var bodyRegionId = e.data.bodyRegionId; - - var grayCanvasID = 'imageCanvas' + bodyRegionId; - var grayCanvas = document.getElementById(grayCanvasID); - var grayCanvasContext = grayCanvas.getContext("2d"); + // alert(e.data.value + '....name= ' + e.data.name) + var updatedData = e.data.value; + // debugger; + for (var i = 1; i <= updatedData.length; i++) { - - - grayCanvasContext.putImageData(upadteddata, 0, 0); + var grayCanvasID = 'imageCanvas' +i; + var grayCanvas = document.getElementById(grayCanvasID); + var grayCanvasContext = grayCanvas.getContext("2d"); + + + + grayCanvasContext.putImageData(updatedData[i], 0, 0); + } + //var upadteddata = e.data.value; + //var bodyRegionId = e.data.bodyRegionId; + + // $rootScope.grayImageDataList[bodyRegionId - 1] = upadteddata; diff --git a/400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js b/400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js index 27d9e55..dcae699 100644 --- a/400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js +++ b/400-SOURCECODE/AIAHTML5.Web/match-pixel-wp.js @@ -1,12 +1,107 @@ - -function getLocationsForMatchedTermsInWholeBody(msg) +previousGrayImageDataList = []; + +function updateGrayCanvasDataOnMatcghedLocation(termList, maskCanvasData, coloreImageData, + grayImageData, grayImageMRDataList, bodyRegionId) { - debugger; + console.log('updateGrayCanvasDataOnMatcghedLocation= ' + bodyRegionId) + + + 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)]; + + } + var grayImageDataVar = grayImageData.data; + var coloredImageDataVar = coloreImageData.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)) { + + + + + // matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i }); + + + // matched = true; - self.postMessage({ 'value': msg }); + 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)] = grayImageData; + + // if (matched == true) { + self.postMessage({ + 'bodyRegionId': bodyRegionId, + 'value': grayImageData, + + + }); + // } } + +} self.onmessage = function (e) { - getLocationsForMatchedTermsInWholeBody(e.data.candata); -} \ No newline at end of file + console.log('shd') + updateGrayCanvasDataOnMatcghedLocation(e.data.termList, e.data.maskCanvasData, e.data.coloreImageData, + e.data.grayImageData, e.data.grayImageMRDataList, e.data.bodyRegionId); + +} + diff --git a/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js b/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js index 08c9c3d..cc7e069 100644 --- a/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js +++ b/400-SOURCECODE/AIAHTML5.Web/term-number-wp.js @@ -1,11 +1,14 @@ -var previousGrayImageDataList = []; +var UpdatedGrayImageDataList = []; +var doneBRID = []; var abc = 'hello'; -getLocationForMatchedTermsInWholeBody = function (TermList, maskCanvasData, coloredImageCanvasList, coloredImageMRCanvasList, grayImageDataList, grayImageMRDataList) { - +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++) { + + for (var x = 0; x < maskCanvasData.length; x++) + { matched = false; // alert('called for bodyRegionId: ' + $scope.MaskImageSRC[x].bodyRegionId); @@ -13,115 +16,67 @@ getLocationForMatchedTermsInWholeBody = function (TermList, maskCanvasData, colo var canvasId = maskCanvasData[x].canvasId; var maskData = maskCanvasData[x].maskData; - var coloredImageDataVar1 = coloredImageCanvasList[bodyRegionId - 1]; - var grayImageDataVar1 = grayImageDataList[bodyRegionId - 1]; + 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 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 coloredImageDataVar = coloredImageDataVar1.data; + //var grayImageDataVar = grayImageDataVar1.data; - var Icolor = (Red + Green + Blue); - // alert('Icolor: ' + Icolor) + var counter = 0; - if (parseInt(TermList[z]._TermNumber) == parseInt(Icolor)) { + var imageDataVar = maskData.data; - counter++; + var machLocationWP = new Worker('match-pixel-wp.js'); + + machLocationWP.postMessage({ - matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i }); + 'termList': termList, + 'maskCanvasData': maskData, + 'coloreImageData': coloredImageDataVar, + 'grayImageData': grayImageDataVar, + 'grayImageMRDataList': grayImageMRDataList, + 'bodyRegionId': bodyRegionId + }); - 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; - + machLocationWP.onmessage = function (e) { + console.log('callback: ' + e.data.value+', x='+x); + + //var upadteddata = e.data.value; + //var bodyRegionId = e.data.bodyRegionId; - var ALPHA_coloredImage = coloredImageDataVar[i + 3]; - grayImageDataVar[i + 3] = ALPHA_coloredImage; + //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 - } - previousGrayImageDataList[parseInt(bodyRegionId - 1)] = grayImageDataVar1; - } + console.log('UpdatedGrayImageDataList: '+ UpdatedGrayImageDataList); - + console.log('doneBRID: ' + doneBRID.length); - if (matched == true) { + if (doneBRID.length==9) { + console.log('before sending UpdatedGrayImageDataList= ' + UpdatedGrayImageDataList) self.postMessage({ - 'bodyRegionId': bodyRegionId, - 'value': grayImageDataVar1, + 'value': UpdatedGrayImageDataList, + 'name': 'Happy' + }) + } + }; + machLocationWP.onerror = function (e) { + console.log('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); + }; - }); - - } + } - - + } @@ -132,20 +87,4 @@ self.onmessage = function (e) { } -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); - }; - - - -}