-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
43 lines (32 loc) · 948 Bytes
/
main.js
File metadata and controls
43 lines (32 loc) · 948 Bytes
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
var dataFn;
function median(arr){
arr.sort(function(a,b){return a-b;});
return arr[Math.floor(arr.length/2)];
}
function max(arr){
return Math.max.apply(null, arr);
}
function min(arr){
return Math.min.apply(null, arr);
}
var c;
var cOut;
var origImg;
var imgData;
//set dataFn to any imageProcess
dataFn = edge;
window.onload = function(){
c = document.getElementById("imageHolder");
cOut = document.getElementById("imageDrawer");
origImg = document.getElementById("inImg");
c.width = origImg.width;
c.height = origImg.height;
cOut.width = origImg.width;
cOut.height = origImg.height;
var ctx = c.getContext("2d");
var ctxOut = cOut.getContext("2d");
ctx.drawImage(origImg, 0, 0, origImg.width, origImg.height);
imgData = ctx.getImageData(0, 0, origImg.width, origImg.height);
var newImgData = dataFn(imgData);
ctxOut.putImageData(newImgData, 0, 0);
};