Commit dd39f0c829b18c8b35e44375ce72bb910650715a
1 parent
23f7d327
We have optimized highlights through worker process but still have scope of improvisation
Showing
4 changed files
with
350 additions
and
181 deletions
400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj
... | ... | @@ -74,7 +74,6 @@ |
74 | 74 | <Content Include="app\views\LabExerc\LabExerc-view.html" /> |
75 | 75 | <Content Include="app\widget\MainMenu.html" /> |
76 | 76 | <Content Include="app\workeroprocess\match-pixel-wp.js" /> |
77 | - <Content Include="app\workeroprocess\term-number-wp.js" /> | |
78 | 77 | <Content Include="content\css\main.css" /> |
79 | 78 | <Content Include="content\data\json\da\body-views\1\da_dat_tm_sg_1.json" /> |
80 | 79 | <Content Include="content\data\json\da\body-views\10\da_dat_body_system_term_10.json" /> | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... | ... | @@ -49,6 +49,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
49 | 49 | // This variable is used for unhighlight previously highlighted body portion, if multiAnnotation is false. |
50 | 50 | $scope.machedIcolorInBodyRegion = []; |
51 | 51 | |
52 | + $scope.MaskCanvasData = []; | |
53 | + | |
52 | 54 | //array for bodyviewid correspoing to male female(used for gender change) |
53 | 55 | $scope.correspondingBodyViewIds = { |
54 | 56 | '1': '5', |
... | ... | @@ -1058,6 +1060,19 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
1058 | 1060 | |
1059 | 1061 | document.getElementById('canvasDiv').appendChild(FlipedImgCanvas); |
1060 | 1062 | |
1063 | + if (FlipedImgCanvas.id.match('_mci')) { | |
1064 | + | |
1065 | + var maskImgData = context.getImageData(0, 0, w, h); | |
1066 | + | |
1067 | + $scope.MaskCanvasData.push( | |
1068 | + { | |
1069 | + "bodyRegionId": bodyRegionId, | |
1070 | + "canvasId": FlipedImgCanvas.id, | |
1071 | + "maskData": maskImgData, | |
1072 | + | |
1073 | + } | |
1074 | + ); | |
1075 | + } | |
1061 | 1076 | |
1062 | 1077 | } |
1063 | 1078 | |
... | ... | @@ -1312,124 +1327,145 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
1312 | 1327 | function start() { |
1313 | 1328 | // debugger; |
1314 | 1329 | context.drawImage(img, 0, 0); |
1330 | + | |
1331 | + if (imgCanvas.id.match('_mci')) { | |
1332 | + var maskImgData = context.getImageData(0, 0, w, h); | |
1333 | + $scope.MaskCanvasData.push( | |
1334 | + { | |
1335 | + "bodyRegionId": bodyRegionId, | |
1336 | + "canvasId": imgCanvas.id, | |
1337 | + "maskData": maskImgData, | |
1338 | + | |
1339 | + } | |
1340 | + ); | |
1341 | + } | |
1315 | 1342 | }; |
1316 | 1343 | |
1317 | 1344 | document.getElementById('canvasDiv').appendChild(imgCanvas); |
1318 | 1345 | |
1346 | + | |
1319 | 1347 | } |
1320 | - | |
1321 | 1348 | $scope.highLightBodyBasedOnIcolor = function (RGBColor) { |
1349 | + | |
1350 | + //2. Find Actul Term No Based on Icolor. | |
1351 | + var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
1322 | 1352 | |
1323 | - $scope.previousSelectedTermList.length=0; | |
1324 | - if ($scope.previousSelectedTermList.length > 0) { | |
1325 | - | |
1326 | - //alert('previousSelectedTermList length: ' + $scope.previousSelectedTermList.length); | |
1327 | - | |
1328 | - for (var i = 0; i < $scope.previousSelectedTermList.length; i++) { | |
1329 | - var RGBColor = $scope.previousSelectedTermList[i]; | |
1353 | + //3. Find Term No List Based on ActualTermNo | |
1354 | + var TermList = $scope.getTermNumberList(ActualTermNo); | |
1330 | 1355 | |
1331 | 1356 | |
1357 | + //4. | |
1332 | 1358 | |
1333 | - //2. Find Actul Term No Based on Icolor. | |
1334 | - var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
1359 | + $scope.machedTermNoLocation = []; | |
1360 | + console.log(' TermList.length= ' + TermList.length) | |
1335 | 1361 | |
1336 | - //3. Find Term No List Based on ActualTermNo | |
1337 | - var TermList = $scope.getTermNumberList(ActualTermNo); | |
1362 | + var worker = new Worker('term-number-wp.js'); | |
1338 | 1363 | |
1364 | + for (var i = 0; i < TermList.length; i++) { | |
1339 | 1365 | |
1340 | - //4. | |
1366 | + console.log('Start time taken for term: ' + TermList[i]._TermNumber + 'in posting: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
1367 | + worker.postMessage({ | |
1368 | + 'termNumber': TermList[i]._TermNumber, | |
1369 | + 'maskCanvasData': $scope.MaskCanvasData | |
1370 | + | |
1371 | + }); | |
1341 | 1372 | |
1342 | - $scope.machedTermNoLocation = []; | |
1343 | - //for (var i = 0; i < TermList.length; i++) { | |
1373 | + } | |
1374 | + worker.onmessage = function (e) { | |
1375 | + console.log('callback time taken : ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
1376 | + $scope.fillMatchedTerm(e.data.value); | |
1344 | 1377 | |
1345 | - // var termNumber = parseInt(TermList[i]._TermNumber); | |
1346 | 1378 | |
1347 | - // //Match Term No List in each bodyRegion | |
1348 | - // $scope.getLocationsForMatchedTermsInWholeBody(termNumber); | |
1349 | - //} | |
1379 | + }; | |
1380 | + worker.onerror = function (e) { | |
1381 | + alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); | |
1382 | + }; | |
1383 | + } | |
1350 | 1384 | |
1351 | 1385 | |
1352 | 1386 | |
1353 | - var worker = new Worker('term-number-wp.js'); | |
1387 | + //$scope.highLightBodyBasedOnIcolor = function (RGBColor) { | |
1354 | 1388 | |
1355 | - | |
1389 | + // $scope.previousSelectedTermList.length = 0; | |
1356 | 1390 | |
1357 | - //start the worker | |
1358 | - worker.postMessage({ | |
1359 | - 'cmd': 'abc', | |
1360 | - 'value': 'send msg from DA controller' | |
1361 | - }); | |
1391 | + // var RGBColor = $scope.previousSelectedTermList[i]; | |
1362 | 1392 | |
1363 | - worker.onmessage = function (e) { | |
1364 | - var msg = e.data.msg; | |
1365 | - }; | |
1366 | - worker.onerror = function (e) { | |
1367 | - alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); | |
1368 | - }; | |
1369 | - } | |
1370 | - } | |
1371 | - else { | |
1372 | - //2. Find Actul Term No Based on Icolor. | |
1373 | - var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
1393 | + // //2. Find Actul Term No Based on Icolor. | |
1394 | + // var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
1374 | 1395 | |
1375 | - //3. Find Term No List Based on ActualTermNo | |
1376 | - var TermList = $scope.getTermNumberList(ActualTermNo); | |
1396 | + // //3. Find Term No List Based on ActualTermNo | |
1397 | + // var TermList = $scope.getTermNumberList(ActualTermNo); | |
1377 | 1398 | |
1399 | + // if ($scope.previousSelectedTermList.length > 0) { | |
1378 | 1400 | |
1379 | - //4. | |
1401 | + // var worker = new Worker('term-number-wp.js'); | |
1380 | 1402 | |
1381 | - $scope.machedTermNoLocation = []; | |
1382 | - for (var i = 0; i < TermList.length; i++) { | |
1383 | 1403 | |
1384 | - var termNumber = parseInt(TermList[i]._TermNumber); | |
1385 | - | |
1386 | - var worker = new Worker('term-number-wp.js'); | |
1404 | + // for (var i = 0; i < $scope.previousSelectedTermList.length; i++) { | |
1405 | + // $scope.machedTermNoLocation = []; | |
1406 | + // for (var i = 0; i < TermList.length; i++) { | |
1387 | 1407 | |
1388 | - | |
1408 | + // var termNumber = parseInt(TermList[i]._TermNumber); | |
1389 | 1409 | |
1390 | - //start the worker | |
1391 | - worker.postMessage({ | |
1392 | - 'cmd': 'abc', | |
1393 | - 'value': 'send msg from DA controller' | |
1394 | - }); | |
1410 | + // // //Match Term No List in each bodyRegion | |
1411 | + // // $scope.getLocationsForMatchedTermsInWholeBody(termNumber); | |
1395 | 1412 | |
1396 | - worker.onmessage = function (e) { | |
1397 | - var msg = e.data.msg; | |
1398 | - }; | |
1399 | - worker.onerror = function (e) { | |
1400 | - alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); | |
1401 | - }; | |
1402 | - //Match Term No List in each bodyRegion | |
1403 | - //$scope.getLocationsForMatchedTermsInWholeBody(termNumber); | |
1404 | - } | |
1413 | + // worker.postMessage({ | |
1414 | + // 'cmd': 'abc', | |
1415 | + // 'value': termNumber | |
1416 | + // }); | |
1417 | + // } | |
1418 | + | |
1419 | + // } | |
1405 | 1420 | |
1406 | - debugger; | |
1407 | - var worker = new Worker('term-number-wp.js'); | |
1421 | + // worker.onmessage = function (e) { | |
1422 | + // var msg = e.data.msg1; | |
1423 | + // }; | |
1424 | + // worker.onerror = function (e) { | |
1425 | + // alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); | |
1426 | + // }; | |
1427 | + // } | |
1428 | + // else { | |
1408 | 1429 | |
1409 | - worker.onmessage = function (e) { | |
1410 | - var msg = e.data.msg; | |
1411 | - }; | |
1412 | - worker.onerror = function (e) { | |
1413 | - alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); | |
1414 | - }; | |
1430 | + // $scope.machedTermNoLocation = []; | |
1431 | + // for (var i = 0; i < TermList.length; i++) { | |
1415 | 1432 | |
1416 | - //start the worker | |
1417 | - worker.postMessage({ | |
1418 | - 'cmd': 'abc', | |
1419 | - 'value': 'send msg from DA controller' | |
1420 | - }); | |
1421 | - } | |
1422 | - } | |
1433 | + // var termNumber = parseInt(TermList[i]._TermNumber); | |
1434 | + | |
1435 | + // var worker = new Worker('term-number-wp.js'); | |
1436 | + | |
1437 | + // //start the worker | |
1438 | + // worker.postMessage({ | |
1439 | + // 'cmd': 'abc', | |
1440 | + // 'value': termNumber | |
1441 | + // }); | |
1442 | + | |
1443 | + // worker.onmessage = function (e) { | |
1444 | + // var msg = e.data.msg; | |
1445 | + // }; | |
1446 | + // worker.onerror = function (e) { | |
1447 | + // alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); | |
1448 | + // }; | |
1449 | + // //Match Term No List in each bodyRegion | |
1450 | + // //$scope.getLocationsForMatchedTermsInWholeBody(termNumber); | |
1451 | + // } | |
1452 | + | |
1453 | + | |
1454 | + // } | |
1455 | + //} | |
1423 | 1456 | |
1424 | 1457 | |
1425 | 1458 | |
1426 | - $scope.getLocationsForMatchedTermsInWholeBody = function (termNo) { | |
1459 | + $scope.fillMatchedTerm = function (matchedLocationData) | |
1460 | + { | |
1461 | + console.log('Start time taken in fillMatchedTerm: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
1427 | 1462 | |
1428 | 1463 | for (var x = 0; x < $scope.ColoredImageSRC.length; x++) { |
1429 | 1464 | // alert('called for bodyRegionId: ' + $scope.MaskImageSRC[x].bodyRegionId); |
1430 | 1465 | var bodyRegionId = $scope.ColoredImageSRC[x].bodyRegionId; |
1431 | 1466 | |
1432 | 1467 | { |
1468 | + | |
1433 | 1469 | var scaledWidth = $scope.ColoredImageSRC[x].Width; |
1434 | 1470 | var scaledHeight = $scope.ColoredImageSRC[x].Height; |
1435 | 1471 | //var maskImg = $scope.ColoredImageSRC[x].SRC; |
... | ... | @@ -1445,17 +1481,17 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
1445 | 1481 | |
1446 | 1482 | |
1447 | 1483 | // 1. get mask canvas for this body region. |
1448 | - var maskCanvasID; | |
1449 | - if ($scope.ColoredImageSRC[x].haveMirror == 'true') { | |
1450 | - maskCanvasID = 'imageCanvas' + bodyRegionId + '_MR_mci'; | |
1451 | - } | |
1452 | - else { | |
1453 | - maskCanvasID = 'imageCanvas' + bodyRegionId + '_mci'; | |
1484 | + //var maskCanvasID; | |
1485 | + //if ($scope.ColoredImageSRC[x].haveMirror == 'true') { | |
1486 | + // maskCanvasID = 'imageCanvas' + bodyRegionId + '_MR_mci'; | |
1487 | + //} | |
1488 | + //else { | |
1489 | + // maskCanvasID = 'imageCanvas' + bodyRegionId + '_mci'; | |
1454 | 1490 | |
1455 | - } | |
1456 | - var maskCanvas = document.getElementById(maskCanvasID); | |
1457 | - var maskCanvasContext = maskCanvas.getContext("2d"); | |
1458 | - var maskImgData = maskCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight); | |
1491 | + //} | |
1492 | + //var maskCanvas = document.getElementById(maskCanvasID); | |
1493 | + //var maskCanvasContext = maskCanvas.getContext("2d"); | |
1494 | + //var maskImgData = maskCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight); | |
1459 | 1495 | |
1460 | 1496 | // 2. get coloured canvas for this body region. |
1461 | 1497 | |
... | ... | @@ -1496,97 +1532,39 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
1496 | 1532 | |
1497 | 1533 | var counter = 0; |
1498 | 1534 | |
1499 | - var imageDataVar = maskImgData.data; | |
1500 | - | |
1501 | - // var previousBRID; | |
1502 | - | |
1503 | - var counter = 0; | |
1504 | - | |
1505 | - | |
1506 | - var n = maskImgData.data.length; | |
1507 | - | |
1508 | - for (var i = 0; i < n; i += 4) { | |
1509 | - | |
1510 | - | |
1511 | - var RED = imageDataVar[i] - 9; | |
1512 | - var GREEN = imageDataVar[i + 1] - 9; | |
1513 | - var BLUE = imageDataVar[i + 2] - 9; | |
1514 | - | |
1515 | - var Red; | |
1516 | - var Green; | |
1517 | - var Blue; | |
1518 | - var zero = "0"; | |
1519 | - | |
1520 | - if ((RED).toString().length != 2) { | |
1521 | - Red = zero.concat((RED).toString()) | |
1522 | - } | |
1523 | - else { | |
1524 | - Red = (RED).toString() | |
1525 | - } | |
1526 | - if ((GREEN).toString().length != 2) { | |
1527 | - Green = zero.concat((GREEN).toString()) | |
1528 | - } | |
1529 | - else { | |
1530 | - Green = (GREEN).toString() | |
1531 | - | |
1532 | - } | |
1533 | - if ((BLUE).toString().length != 2) { | |
1534 | - Blue = zero.concat((BLUE).toString()) | |
1535 | - } | |
1536 | - else { | |
1537 | - Blue = (BLUE).toString() | |
1538 | - | |
1539 | - } | |
1540 | - | |
1541 | - var Icolor = (Red + Green + Blue); | |
1542 | - // alert('Icolor: ' + Icolor) | |
1543 | - | |
1544 | - if (parseInt(termNo) == parseInt(Icolor)) { | |
1545 | - | |
1546 | - counter++; | |
1547 | - var have = $scope.machedIcolorInBodyRegion.indexOf(bodyRegionId); | |
1548 | - | |
1549 | - | |
1550 | - if (have == -1) { | |
1551 | - $scope.machedIcolorInBodyRegion.push(bodyRegionId); | |
1552 | - } | |
1553 | - else { | |
1554 | - | |
1555 | - } | |
1556 | - | |
1557 | - | |
1558 | - //previousGrayColoredData = i; | |
1559 | - if (coloredImageDataVar != null) { | |
1560 | - | |
1561 | 1535 | |
1562 | - var RED_coloredImage = coloredImageDataVar[i]; | |
1536 | + var dataForthisBR = new jinqJs() | |
1537 | + .from(matchedLocationData) | |
1538 | + .where('BRId == ' + bodyRegionId) | |
1539 | + .select(); | |
1563 | 1540 | |
1564 | - grayImageDataVar[i] = RED_coloredImage; | |
1541 | + for (var z = 0; z < dataForthisBR.length; z++) | |
1542 | + { | |
1543 | + var location = parseInt(dataForthisBR[z].location); | |
1544 | + | |
1565 | 1545 | |
1546 | + var RED_coloredImage = coloredImageDataVar[location]; | |
1566 | 1547 | |
1567 | - var GREEN_coloredImage = coloredImageDataVar[i + 1]; | |
1568 | - grayImageDataVar[i + 1] = GREEN_coloredImage; | |
1548 | + grayImageDataVar[location] = RED_coloredImage; | |
1569 | 1549 | |
1570 | - var BLUE_coloredImage = coloredImageDataVar[i + 2]; | |
1571 | - grayImageDataVar[i + 2] = BLUE_coloredImage; | |
1572 | 1550 | |
1551 | + var GREEN_coloredImage = coloredImageDataVar[location + 1]; | |
1552 | + grayImageDataVar[location + 1] = GREEN_coloredImage; | |
1573 | 1553 | |
1574 | - var ALPHA_coloredImage = coloredImageDataVar[i + 3]; | |
1575 | - grayImageDataVar[i + 3] = ALPHA_coloredImage; | |
1554 | + var BLUE_coloredImage = coloredImageDataVar[location + 2]; | |
1555 | + grayImageDataVar[location + 2] = BLUE_coloredImage; | |
1576 | 1556 | |
1577 | 1557 | |
1578 | - } | |
1558 | + var ALPHA_coloredImage = coloredImageDataVar[location + 3]; | |
1559 | + grayImageDataVar[location + 3] = ALPHA_coloredImage; | |
1579 | 1560 | |
1580 | - } | |
1581 | - | |
1582 | - // grayCanvasContext.putImageData(grayImageData, 0, 0); | |
1583 | 1561 | } |
1584 | - | |
1585 | 1562 | grayCanvasContext.putImageData(grayImageData, 0, 0); |
1586 | 1563 | } |
1587 | - } | |
1588 | 1564 | |
1565 | + } | |
1589 | 1566 | |
1567 | + console.log('End time taken in fillMatchedTerm: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
1590 | 1568 | } |
1591 | 1569 | |
1592 | 1570 | $scope.GetRGBColor = function (maskCanvasContext, actulalX, actualY, x, y) { | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/workeroprocess/term-number-wp.js
... | ... | @@ -2,14 +2,19 @@ |
2 | 2 | { |
3 | 3 | |
4 | 4 | |
5 | - var msg1 = msg; | |
6 | - | |
5 | + var msg1 = msg; | |
6 | + alert(msg1); | |
7 | + worker.postMessage({ | |
8 | + 'cmd': 'getLocationsForMatchedTermsInWholeBody', | |
9 | + 'value': msg1 | |
10 | + }); | |
7 | 11 | |
8 | 12 | |
9 | 13 | } |
10 | 14 | |
11 | 15 | self.onmessage = function (e) { |
12 | - abc(e.data.value); | |
16 | + abc(e.data.termNumber); | |
17 | + | |
13 | 18 | } |
14 | 19 | |
15 | 20 | function launchMatchPixelWorkerProcess() { |
... | ... | @@ -26,9 +31,6 @@ function launchMatchPixelWorkerProcess() { |
26 | 31 | }; |
27 | 32 | |
28 | 33 | |
29 | - worker.postMessage({ | |
30 | - 'cmd': 'getLocationsForMatchedTermsInWholeBody', | |
31 | - 'value': 'msg from term-number-wp' | |
32 | - }); | |
34 | + | |
33 | 35 | } |
34 | 36 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/term-number-wp.js
1 | -๏ปฟfunction abc(msg) | |
2 | -{ | |
1 | +๏ปฟfunction abc(msg) { | |
2 | + | |
3 | + | |
4 | + var msg1 = msg; | |
3 | 5 | |
4 | - var msg1 = msg; | |
6 | + self.postMessage({ | |
7 | + 'cmd': 'getLocationForMatchedTermsInWholeBody', | |
8 | + 'value': msg1 | |
9 | + }); | |
10 | + | |
11 | + | |
12 | +} | |
13 | + | |
14 | +getLocationForMatchedTermsInWholeBody = function (termNo, maskCanvasData) | |
15 | +{ | |
16 | + | |
17 | + var matchedRGBLocationInBodyRegion = []; | |
18 | + for (var x = 0; x < maskCanvasData.length; x++) { | |
19 | + // alert('called for bodyRegionId: ' + $scope.MaskImageSRC[x].bodyRegionId); | |
20 | + var bodyRegionId = maskCanvasData[x].bodyRegionId; | |
21 | + var canvasId = maskCanvasData[x].canvasId; | |
22 | + var maskData = maskCanvasData[x].maskData; | |
23 | + | |
24 | + // { | |
25 | + //var scaledWidth = $scope.ColoredImageSRC[x].Width; | |
26 | + //var scaledHeight = $scope.ColoredImageSRC[x].Height; | |
27 | + ////var maskImg = $scope.ColoredImageSRC[x].SRC; | |
28 | + | |
29 | + | |
30 | + //var coloredImg = $scope.ColoredImageSRC[x].SRC; | |
31 | + | |
32 | + //var maskImg = $scope.GetMaskImageSource(coloredImg); | |
33 | + | |
34 | + | |
35 | + //var scledX = $scope.ColoredImageSRC[x].x; | |
36 | + //var scledY = $scope.ColoredImageSRC[x].y; | |
37 | + | |
38 | + | |
39 | + //// 1. get mask canvas for this body region. | |
40 | + //var maskCanvasID; | |
41 | + //if ($scope.ColoredImageSRC[x].haveMirror == 'true') { | |
42 | + // maskCanvasID = 'imageCanvas' + bodyRegionId + '_MR_mci'; | |
43 | + //} | |
44 | + //else { | |
45 | + // maskCanvasID = 'imageCanvas' + bodyRegionId + '_mci'; | |
46 | + | |
47 | + //} | |
48 | + //var maskCanvas = document.getElementById(maskCanvasID); | |
49 | + //var maskCanvasContext = maskCanvas.getContext("2d"); | |
50 | + //var maskImgData = maskCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight); | |
51 | + | |
52 | + //// 2. get coloured canvas for this body region. | |
53 | + | |
54 | + | |
55 | + //var coloredImageDataVar; | |
56 | + //var coloredImageDataMRVar | |
57 | + | |
58 | + //if ($scope.ColoredImageSRC[x].haveMirror == 'true') { | |
59 | + | |
60 | + // coloredImageDataVar = $rootScope.coloredImageMRCanvasList[parseInt(bodyRegionId)]; | |
61 | + //} | |
62 | + //else { | |
63 | + // coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(bodyRegionId - 1)]; | |
64 | + //} | |
65 | + | |
66 | + //var grayImageDataVar; | |
67 | + //var grayCanvas; | |
68 | + //if ($scope.ColoredImageSRC[x].haveMirror == 'true') { | |
69 | + | |
70 | + // //// 3. get mask canvas for this body region._MR | |
71 | + // var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR'; | |
72 | + // grayCanvas = document.getElementById(grayCanvasID); | |
73 | + // var grayCanvasContext = grayCanvas.getContext("2d"); | |
74 | + // var grayImageData = grayCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight); | |
75 | + // grayImageDataVar = grayImageData.data; | |
76 | + //} | |
77 | + | |
78 | + //else { | |
79 | + // var grayCanvasID = 'imageCanvas' + bodyRegionId; | |
80 | + // grayCanvas = document.getElementById(grayCanvasID); | |
81 | + // var grayCanvasContext = grayCanvas.getContext("2d"); | |
82 | + // var grayImageData = grayCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight); | |
83 | + // grayImageDataVar = grayImageData.data; | |
84 | + //} | |
85 | + | |
86 | + //var coloredImageDataVarMR; | |
87 | + //var coloredImageDataMR | |
88 | + | |
89 | + | |
90 | + var counter = 0; | |
91 | + | |
92 | + var imageDataVar = maskData.data; | |
93 | + | |
94 | + // var previousBRID; | |
95 | + | |
96 | + var counter = 0; | |
97 | + | |
98 | + | |
99 | + var n = maskData.data.length; | |
100 | + | |
101 | + for (var i = 0; i < n; i += 4) { | |
102 | + | |
103 | + | |
104 | + var RED = imageDataVar[i] - 9; | |
105 | + var GREEN = imageDataVar[i + 1] - 9; | |
106 | + var BLUE = imageDataVar[i + 2] - 9; | |
107 | + | |
108 | + var Red; | |
109 | + var Green; | |
110 | + var Blue; | |
111 | + var zero = "0"; | |
112 | + | |
113 | + if ((RED).toString().length != 2) { | |
114 | + Red = zero.concat((RED).toString()) | |
115 | + } | |
116 | + else { | |
117 | + Red = (RED).toString() | |
118 | + } | |
119 | + if ((GREEN).toString().length != 2) { | |
120 | + Green = zero.concat((GREEN).toString()) | |
121 | + } | |
122 | + else { | |
123 | + Green = (GREEN).toString() | |
124 | + | |
125 | + } | |
126 | + if ((BLUE).toString().length != 2) { | |
127 | + Blue = zero.concat((BLUE).toString()) | |
128 | + } | |
129 | + else { | |
130 | + Blue = (BLUE).toString() | |
131 | + | |
132 | + } | |
133 | + | |
134 | + var Icolor = (Red + Green + Blue); | |
135 | + // alert('Icolor: ' + Icolor) | |
136 | + | |
137 | + if (parseInt(termNo) == parseInt(Icolor)) { | |
138 | + | |
139 | + counter++; | |
140 | + | |
141 | + //var obj = new Object(); | |
142 | + //obj.bodyRegionId = bodyRegionId; | |
143 | + //obj.location = i; | |
144 | + | |
145 | + matchedRGBLocationInBodyRegion.push({ "BRId": bodyRegionId, "location": i }); | |
146 | + | |
147 | + // var have = machedIcolorInBodyRegion.indexOf(bodyRegionId); | |
148 | + | |
149 | + | |
150 | + //if (have == -1) { | |
151 | + // // machedIcolorInBodyRegion.push(bodyRegionId); | |
152 | + //} | |
153 | + //else { | |
154 | + | |
155 | + //} | |
156 | + | |
157 | + | |
158 | + //previousGrayColoredData = i; | |
159 | + //if (coloredImageDataVar != null) { | |
160 | + | |
161 | + | |
162 | + // var RED_coloredImage = coloredImageDataVar[i]; | |
163 | + | |
164 | + // // grayImageDataVar[i] = RED_coloredImage; | |
165 | + | |
166 | + | |
167 | + // var GREEN_coloredImage = coloredImageDataVar[i + 1]; | |
168 | + // /// grayImageDataVar[i + 1] = GREEN_coloredImage; | |
169 | + | |
170 | + // var BLUE_coloredImage = coloredImageDataVar[i + 2]; | |
171 | + // //grayImageDataVar[i + 2] = BLUE_coloredImage; | |
172 | + | |
173 | + | |
174 | + // var ALPHA_coloredImage = coloredImageDataVar[i + 3]; | |
175 | + // // grayImageDataVar[i + 3] = ALPHA_coloredImage; | |
176 | + | |
177 | + | |
178 | + //} | |
179 | + | |
180 | + } | |
181 | + | |
182 | + | |
183 | + // grayCanvasContext.putImageData(grayImageData, 0, 0); | |
184 | + } | |
185 | + self.postMessage({ | |
186 | + 'cmd': 'getLocationsForMatchedTermsInWholeBody', | |
187 | + 'value': matchedRGBLocationInBodyRegion | |
188 | + }); | |
189 | + | |
190 | + // grayCanvasContext.putImageData(grayImageData, 0, 0); | |
191 | + //} | |
192 | + | |
193 | + | |
194 | + } | |
195 | + | |
196 | + | |
197 | + | |
5 | 198 | |
6 | - | |
7 | 199 | } |
8 | 200 | |
9 | 201 | self.onmessage = function (e) { |
10 | - abc(e.data.value); | |
202 | + getLocationForMatchedTermsInWholeBody(e.data.termNumber, e.data.maskCanvasData); | |
203 | + | |
11 | 204 | } |
12 | 205 | |
13 | 206 | function launchMatchPixelWorkerProcess() { |
14 | - | |
207 | + | |
15 | 208 | var worker = new Worker('match-pixel-wp.js'); |
16 | 209 | |
17 | 210 | worker.onmessage = function (e) { |
... | ... | @@ -23,10 +216,7 @@ function launchMatchPixelWorkerProcess() { |
23 | 216 | alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); |
24 | 217 | }; |
25 | 218 | |
26 | - | |
27 | - worker.postMessage({ | |
28 | - 'cmd': 'getLocationsForMatchedTermsInWholeBody', | |
29 | - 'value': 'msg from term-number-wp' | |
30 | - }); | |
219 | + | |
220 | + | |
31 | 221 | } |
32 | 222 | ... | ... |