Commit 9b2ebaff6edf18814848fc4e3f6ced2a3f85e775

Authored by Amrita Vishnoi
1 parent 79a4d87f

extract in progress...

400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... ... @@ -30,12 +30,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
30 30 $scope.TBDrawStartY;
31 31  
32 32 $rootScope.isHighLight = false;
  33 + $rootScope.isExtract = false;
33 34 $rootScope.coloredImageCanvasList = [];
34 35 $rootScope.coloredImageMRCanvasList = [];
35 36 $rootScope.ColoredCanvasData = [];
36 37 $rootScope.grayImageDataList = [];
37 38 $rootScope.grayImageMRDataList = [];
38 39  
  40 + $rootScope.whiteImageDataList = [];
  41 + $rootScope.whiteImageMRDataList = [];
  42 +
39 43 $rootScope.grayImageDataListCurrent = [];
40 44 $rootScope.grayImageMRDataListCurrent = [];
41 45  
... ... @@ -52,7 +56,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
52 56 // This variable is used for unhighlight previously highlighted body portion, if multiAnnotation is false.
53 57 $scope.machedIcolorInBodyRegion = [];
54 58  
55   - $scope.MaskCanvasData = [];
  59 + $rootScope.MaskCanvasData = [];
  60 +
  61 + $rootScope.previousHighlightList = [];
56 62  
57 63 //array for bodyviewid correspoing to male female(used for gender change)
58 64 $scope.correspondingBodyViewIds = {
... ... @@ -454,17 +460,17 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
454 460  
455 461 // debugger;
456 462 //remove the previous layer mask data from array
457   - var n = $scope.MaskCanvasData.length
  463 + var n = $rootScope.MaskCanvasData.length
458 464  
459 465 if (n > 0) {
460 466 for (var i = n - 1; i >= 0; i--) {
461 467  
462   - $scope.MaskCanvasData.splice(i, 1);
  468 + $rootScope.MaskCanvasData.splice(i, 1);
463 469 // workerCount--;
464 470 }
465 471  
466   - $scope.MaskCanvasData = null;
467   - $scope.MaskCanvasData = [];
  472 + $rootScope.MaskCanvasData = null;
  473 + $rootScope.MaskCanvasData = [];
468 474 }
469 475  
470 476 //set height of canvas div and left tool bar as per window size
... ... @@ -1076,7 +1082,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1076 1082  
1077 1083 var maskImgData = context.getImageData(0, 0, w, h);
1078 1084  
1079   - $scope.MaskCanvasData.push(
  1085 + $rootScope.MaskCanvasData.push(
1080 1086 {
1081 1087 "bodyRegionId": bodyRegionId,
1082 1088 "canvasId": FlipedImgCanvas.id,
... ... @@ -1228,6 +1234,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1228 1234  
1229 1235 var grayImageData = $rootScope.grayImageDataList[bodyRegionId - 1];
1230 1236  
  1237 + // this code is used to unhighlight on next click
1231 1238 grayCanvasContext.putImageData(grayImageData, 0, 0)
1232 1239  
1233 1240 // for unhighlight the mirrored body region
... ... @@ -1246,8 +1253,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1246 1253 }
1247 1254 }
1248 1255  
1249   - // var IcolorWithCordinate = new Object;
1250   - var previousIcolor = RGBColor;
  1256 + $rootScope.previousHighlightList.push(RGBColor);
  1257 +
  1258 + var previousIcolor = RGBColor; //ami
1251 1259 //var previousX;
1252 1260 // var previousY;
1253 1261  
... ... @@ -1352,7 +1360,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1352 1360  
1353 1361 if (imgCanvas.id.match('_mci')) {
1354 1362 var maskImgData = context.getImageData(0, 0, w, h);
1355   - $scope.MaskCanvasData.push(
  1363 + $rootScope.MaskCanvasData.push(
1356 1364 {
1357 1365 "bodyRegionId": bodyRegionId,
1358 1366 "canvasId": imgCanvas.id,
... ... @@ -1397,29 +1405,41 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1397 1405 $scope.machedTermNoLocation = [];
1398 1406  
1399 1407  
1400   - var n = $scope.MaskCanvasData.length;
1401   - console.log('$scope.MaskCanvasData.length= ' + n)
  1408 + var n = $rootScope.MaskCanvasData.length;
  1409 + console.log('$rootScope.MaskCanvasData.length= ' + n)
1402 1410  
1403 1411 // console.log('Start time taken for term: ' + TermList[i]._TermNumber + 'in posting: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
1404 1412 // debugger
1405 1413 for (var x = 0; x < 9; x++) {
1406   - console.log('$scope.MaskCanvasData.length= ' + n)
  1414 + console.log('$rootScope.MaskCanvasData.length= ' + n)
1407 1415  
1408   - var bodyRegionId = $scope.MaskCanvasData[x].bodyRegionId;
1409   - var canvasId = $scope.MaskCanvasData[x].canvasId;
1410   - var maskData = $scope.MaskCanvasData[x].maskData;
  1416 + var bodyRegionId = $rootScope.MaskCanvasData[x].bodyRegionId;
  1417 + var canvasId = $rootScope.MaskCanvasData[x].canvasId;
  1418 + var maskData = $rootScope.MaskCanvasData[x].maskData;
1411 1419  
1412 1420 var coloredImageDataVar;
1413 1421 var grayImageDataVar;
1414 1422  
1415 1423 if (canvasId.match('_MR')) {
1416 1424 coloredImageDataVar = $rootScope.coloredImageMRCanvasList[bodyRegionId];
1417   - if ($scope.multiAnnotationIsON == true) {
  1425 +
  1426 +
  1427 + if ($scope.multiAnnotationIsON == true)
  1428 + {
1418 1429  
1419 1430 grayImageDataVar = $rootScope.grayImageMRDataListCurrent[bodyRegionId]
1420 1431 }
1421 1432 else
1422 1433 grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
  1434 +
  1435 + if ($rootScope.isExtract) {
  1436 + if ($scope.multiAnnotationIsON == true) {
  1437 +
  1438 + grayImageDataVar = $rootScope.grayImageMRDataListCurrent[bodyRegionId]
  1439 + }
  1440 + else
  1441 + grayImageDataVar = $rootScope.whiteImageMRDataList[bodyRegionId];
  1442 + }
1423 1443 }
1424 1444  
1425 1445 else {
... ... @@ -1430,6 +1450,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1430 1450 }
1431 1451 else
1432 1452 grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
  1453 +
  1454 +
  1455 + if ($rootScope.isExtract) {
  1456 + if ($scope.multiAnnotationIsON == true) {
  1457 +
  1458 + grayImageDataVar = $rootScope.grayImageDataListCurrent[bodyRegionId]
  1459 + }
  1460 + else
  1461 + grayImageDataVar = $rootScope.whiteImageDataList[bodyRegionId];
  1462 + }
1433 1463 }
1434 1464  
1435 1465 //var coloredImageDataVar = $rootScope.coloredImageCanvasList[bodyRegionId - 1];
... ... @@ -3205,9 +3235,30 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3205 3235  
3206 3236 }
3207 3237  
  3238 + $scope.enableExtract = function ()
  3239 + {
  3240 + alert('extract called');
  3241 +
  3242 + debugger;
  3243 +
  3244 + if ($rootScope.isExtract == true) {
  3245 +
  3246 + }
  3247 + else {
  3248 + $rootScope.isExtract = true;
  3249 +
  3250 + //1.
  3251 + $scope.highLightBody();
  3252 +
  3253 +
  3254 + }
  3255 + }
  3256 +
  3257 +
3208 3258  
3209 3259 $scope.highLightBody = function () {
3210 3260  
  3261 + // debugger;
3211 3262  
3212 3263 if ($rootScope.isHighLight == true) {
3213 3264  
... ... @@ -3232,7 +3283,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3232 3283 var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
3233 3284 var coloredImageDataVar = coloredImageData;
3234 3285  
3235   -
3236 3286 if (value.haveMirror == 'true') {
3237 3287 $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar;
3238 3288 }
... ... @@ -3243,6 +3293,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3243 3293  
3244 3294 }
3245 3295  
  3296 +
  3297 +
3246 3298  
3247 3299 var context_gray = imageCanvas.getContext('2d');
3248 3300  
... ... @@ -3258,31 +3310,32 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3258 3310  
3259 3311 img.onload = function () {
3260 3312 //console.log(Math.max(img.width) + ', ' + Math.max(img.height))
3261   -
  3313 + // debugger;
3262 3314 var DAData = new BitmapData(Math.max(img.width), Math.max(img.height));
3263 3315 DAData.draw(img);
3264   - var RED = 0.3086; // luminance contrast value for red
3265   - var GREEN = 0.694; // luminance contrast value for green
3266   - var BLUE = 0.0820; // luminance contrast value for blue
  3316 +
  3317 + var colorMode;
3267 3318  
3268   - var RGB = [RED, GREEN, BLUE, 0, 0];
3269   - var RGB2 = [RED, GREEN, BLUE, 0, 0];
3270   - var RGB3 = [RED, GREEN, BLUE, 0, 0];
3271   - var ALPHA = [0, 0, 0, 1, 0];
3272   -
3273   - var rgbPx = RGB.concat(RGB2);
3274   - var rgbPx2 = rgbPx.concat(RGB3);
3275   - var matrix = rgbPx2.concat(ALPHA);
  3319 + if ($rootScope.isExtract) {
  3320 + colorMode = $scope.applyWhiteMatrix();
  3321 + }
  3322 + else {
  3323 + colorMode = $scope.applyGrayMatrix();
  3324 + }
  3325 + // debugger;
3276 3326  
3277 3327 var zeroPoint = new Point();
3278   - var grayScale = new ColorMatrixFilter(matrix);
3279   - DAData.applyFilter(DAData, DAData.rect, zeroPoint, grayScale);
  3328 + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode);
3280 3329  
3281 3330 context_gray.putImageData(DAData.data, 0, 0)
3282 3331  
  3332 + //2.
  3333 +
  3334 +
3283 3335 var grayImageData = context_gray.getImageData(0, 0, width, ht);
3284 3336 var grayImageImageDataVar = grayImageData.data;
3285 3337  
  3338 +
3286 3339 if (value.haveMirror == 'true') {
3287 3340 $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
3288 3341 }
... ... @@ -3291,21 +3344,35 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3291 3344  
3292 3345 $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
3293 3346 }
  3347 +
  3348 + if ($rootScope.isExtract) {
  3349 +
  3350 + if (value.haveMirror == 'true') {
  3351 + $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = coloredImageDataVar;
  3352 + }
  3353 + else {
  3354 + //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1;
  3355 +
  3356 + $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar;
  3357 +
  3358 + }
  3359 + }
3294 3360 }
3295 3361  
3296 3362 $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50);
3297 3363 })
3298 3364  
3299 3365  
3300   - //if ($scope.previousSelectedTermList.length > 0) {
3301 3366  
3302   - // //alert('previousSelectedTermList length: ' + $scope.previousSelectedTermList.length);
  3367 + if ($rootScope.isExtract) {
  3368 + if ($rootScope.previousHighlightList.length > 0) {
  3369 + angular.forEach($rootScope.previousHighlightList, function (value, key) {
3303 3370  
3304   - // for (var i = 0; i < $scope.previousSelectedTermList.length; i++) {
3305   - // $scope.highLightBodyBasedOnIcolor($scope.previousSelectedTermList[i]);
  3371 + $scope.highLightBodyBasedOnIcolor(value);
3306 3372  
3307   - // }
3308   - //}
  3373 + });
  3374 + }
  3375 + }
3309 3376  
3310 3377 }
3311 3378 }
... ... @@ -3313,8 +3380,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3313 3380  
3314 3381  
3315 3382 $scope.applyGrayMatrix = function (img, context_gray) {
3316   - var DAData = new BitmapData(img.width, img.height);
3317   - DAData.draw(img);
3318 3383 var RED = 0.3086; // luminance contrast value for red
3319 3384 var GREEN = 0.694; // luminance contrast value for green
3320 3385 var BLUE = 0.0820; // luminance contrast value for blue
... ... @@ -3328,15 +3393,30 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3328 3393 var rgbPx2 = rgbPx.concat(RGB3);
3329 3394 var matrix = rgbPx2.concat(ALPHA);
3330 3395  
3331   - var zeroPoint = new Point();
  3396 +
3332 3397 var grayScale = new ColorMatrixFilter(matrix);
3333   - DAData.applyFilter(DAData, DAData.rect, zeroPoint, grayScale);
3334 3398  
3335   - context_gray.putImageData(DAData.data, 0, 0)
  3399 + return grayScale;
  3400 + }
  3401 +
  3402 + $scope.applyWhiteMatrix = function (img, context_gray) {
  3403 + var RED = 255; // white color value for red
  3404 + var GREEN = 255; // white color value for green
  3405 + var BLUE = 255; // white color value for blue
3336 3406  
3337   - var grayImageData = context_gray.getImageData(0, 0, width, ht);
3338   - var grayImageImageDataVar = grayImageData.data;
  3407 + var RGB = [RED, GREEN, BLUE, 0, 0];
  3408 + var RGB2 = [RED, GREEN, BLUE, 0, 0];
  3409 + var RGB3 = [RED, GREEN, BLUE, 0, 0];
  3410 + var ALPHA = [0, 0, 0, 1, 0];
  3411 +
  3412 + var rgbPx = RGB.concat(RGB2);
  3413 + var rgbPx2 = rgbPx.concat(RGB3);
  3414 + var matrix = rgbPx2.concat(ALPHA);
  3415 +
  3416 +
  3417 + var grayScale = new ColorMatrixFilter(matrix);
3339 3418  
  3419 + return grayScale;
3340 3420 }
3341 3421  
3342 3422 $scope.getActualTermNumber = function (iColor) {
... ...
400-SOURCECODE/AIAHTML5.Web/app/views/da/da-view.html
... ... @@ -40,7 +40,7 @@
40 40 <button class="btn btn-primary btn-sm marginTop5"> <img src="content/images/bulb1.png" alt="" title=""></button>
41 41 </div>
42 42 <div class="col-sm-6" title="Extract">
43   - <button class="btn btn-black btn-sm pull-right marginTop5"><img src="content/images/bulb1.png" alt="" title=""></button>
  43 + <button class="btn btn-black btn-sm pull-right marginTop5" ng-click="enableExtract()"><img src="content/images/bulb1.png" alt="" title=""></button>
44 44 </div>
45 45 <div class="col-sm-6" title="Highlight">
46 46 <button id="btnHighLight" class="btn btn-black btn-sm marginTop5" ng-click="enableHighlight()"> <img src="content/images/bulb.png" alt="" title=""></button>
... ...
400-SOURCECODE/AIAHTML5.Web/term-number-wp.js
... ... @@ -16,7 +16,11 @@ getLocationForMatchedTermsInWholeBody = function (termList, maskCanvasData, colo
16 16 grayImageData = previousGrayImageDataList[parseInt(bodyRegionId - 1)];
17 17  
18 18 }
19   - var grayImageDataVar = grayImageData.data;
  19 +
  20 + var grayImageDataVar;
  21 + if (grayImageData != null) {
  22 + grayImageDataVar = grayImageData.data;
  23 + }
20 24 var coloredImageDataVar = coloredImageData.data;
21 25  
22 26 for (var i = 0; i < n; i += 4) {
... ...