ImageDataController.js
10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
'use strict';
var AIA = angular.module('AIA', []);
AIA.controller("ImageDataController", ["$rootScope", "ImageService","DataService",
function ($rootScope, ImageService, DataService) {
$rootScope.JsonDataArray = [];
$rootScope.imageDataArray = [];
$rootScope.normalImageData = [];
$rootScope.grayImageData = [];
$rootScope.maskImageData = [];
$rootScope.sendImageData = function () {
{
var imageData=[];
//imageData = getImageData();
//console.log('image data is created ' + ImageData)
//1.
$rootScope.getdata();
//2.
//$rootScope.processLayerData();
}
}
$rootScope.getdata = function () {
{
var layerJsonPath = '/Content/da_dat_layer_1.json';
DataService.getJson(layerJsonPath)
.then(
function (result) {
//debugger;
$rootScope.BodyLayerData = result;
console.log($rootScope.BodyLayerData);
angular.forEach($rootScope.BodyLayerData, function (value, key) {
// debugger;
angular.forEach(value.DataLayer, function (value1,key1) {
if (value1._LayerNumber == 50)
{
alert('come in 50 layer')
angular.forEach(value1.BodyRegion, function (value2,key2) {
// debugger;
if (value2._BodyRegionId == "1") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "676", "width": "474" });
}
else if (value2._BodyRegionId == "2") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "844", "width": "756" });
}
else if (value2._BodyRegionId == "3") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "932", "width": "948" });
}
else if (value2._BodyRegionId == "4") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "934", "width": "576" });
}
else if (value2._BodyRegionId == "5") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "944", "width": "576" });
}
else {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "1504", "width": "1140" });
}
})
}
else
{
console.log('50 layer not found');
}
for (var i = 0; i <= $rootScope.JsonDataArray.length - 1; i++) {
var srcs = "Content/images/DA/75/body-views/1/layers/50/" + $rootScope.JsonDataArray[i].bodyRegionID + "/" + $rootScope.JsonDataArray[i].imageName + "";
$("#scream").attr("src", srcs);
$("#scream").attr("width", $rootScope.JsonDataArray[i].width);
$("#scream").attr("height", $rootScope.JsonDataArray[i].height);
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img, 0, 0, $rootScope.JsonDataArray[i].width, $rootScope.JsonDataArray[i].height);
var imgData = ctx.getImageData(0, 0, $rootScope.JsonDataArray[i].width, $rootScope.JsonDataArray[i].height);
$rootScope.normalImageData.push({ "DataForNormalImage": imgData.data, "NormalImageName": $rootScope.JsonDataArray[i].imageName, "NormalImageBodyRegionID": $rootScope.JsonDataArray[i].bodyRegionID });
}
for (var i = 0; i <= $rootScope.JsonDataArray.length - 1; i++) {
var mciImage = $rootScope.JsonDataArray[i].imageName.split(".");
var mciImageName = mciImage[0] + "_mci" + ".jpg";
var srcs = "content/images/DA/75/body-views/1/layers/50/" + $rootScope.JsonDataArray[i].bodyRegionID + "/" + mciImageName + "";
$("#scream").attr("src", srcs);
$("#scream").attr("width", $rootScope.JsonDataArray[i].width);
$("#scream").attr("height", $rootScope.JsonDataArray[i].height);
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img, 0, 0, $rootScope.JsonDataArray[i].width, $rootScope.JsonDataArray[i].height);
var imgData = ctx.getImageData(0, 0, $rootScope.JsonDataArray[i].width, $rootScope.JsonDataArray[i].height);
$rootScope.maskImageData.push({ "DataForMciImage": imgData.data, "MciImageName": $rootScope.JsonDataArray[i].imageName, "MciImageBodyRegionID": $rootScope.JsonDataArray[i].bodyRegionID });
ImageService.sendImageDataArray($rootScope.maskImageData);
}
for (var i = 0; i <= $rootScope.JsonDataArray.length - 1; i++) {
var srcs = "content/images/DA/75/body-views/1/layers/50/" + $rootScope.JsonDataArray[i].bodyRegionID + "/";
$("#scream").attr("src", srcs);
$("#scream").attr("width", $rootScope.JsonDataArray[i].width);
$("#scream").attr("height",$rootScope.JsonDataArray[i].height);
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var RED = 0.3086; // luminance contrast value for red
var GREEN = 0.694; // luminance contrast value for green
var BLUE = 0.0820; // luminance contrast value for blue
var RGB = [RED, GREEN, BLUE, 0, 0];
var RGB2 = [RED, GREEN, BLUE, 0, 0];
var RGB3 = [RED, GREEN, BLUE, 0, 0];
var ALPHA = [0, 0, 0, 1, 0];
var rgbPx = RGB.concat(RGB2);
var rgbPx2 = rgbPx.concat(RGB3);
var matrix = rgbPx2.concat(ALPHA);
var grayScale = new ColorMatrixFilter(matrix);
$rootScope.grayImageData.push({ "DataForGrayImage": grayScale.matrix, "GrayImageName": $rootScope.JsonDataArray[i].imageName, "GrayImageBodyRegionID": $rootScope.JsonDataArray[i].bodyRegionID });
}
console.log($rootScope.imageDataArray)
})
})
},
function (error) {
// handle errors here
console.log(' $rootScope.BodyLayerData= ' + error.statusText);
}
);
}
}
$rootScope.processLayerData= function()
{
angular.forEach($rootScope.BodyLayerData, function (value, key) {
angular.forEach(value.DataLayer, function (key1, value1) {
if (value1._LayerNumber == 50) {
angular.forEach(value1.BodyRegion, function (key2, value2) {
if (value2._BodyRegionId == "1") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "676", "width": "474" });
}
else if (value2._BodyRegionId == "2") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "844", "width": "756" });
}
else if (value2._BodyRegionId == "3") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "932", "width": "948" });
}
else if (value2._BodyRegionId == "4") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "934", "width": "576" });
}
else if (value2._BodyRegionId == "5") {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "944", "width": "576" });
}
else {
$rootScope.JsonDataArray.push({ "imageName": value2.Image._ImageName, "bodyRegionID": value2._BodyRegionId, "height": "1504", "width": "1140" });
}
})
}
})
})
}
}]);