-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.html
122 lines (103 loc) · 4.23 KB
/
test2.html
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
<!doctype html>
<html>
<head>
<title>Canvas Test</title>
<style type="text/css">
body {
background-color: #bbb;
color: #333;
}
#container {
text-align: center;
}
img, canvas {
display: inline-block;
}
h1, p {
clear: left;
text-align: center;
font-family: Lucida Grande;
}
</style>
</head>
<body>
<div id="container">
<h1>Magnitude Map </h1>
<p>Using a fast, efficient, and simple edge detection algorithm taken from the paper written by <a href="http://assassinationscience.com/johncostella/">John Costella</a></p>
<img id="candidate" /><canvas id="test" width="1" height="1">
<p>well that sucks</p>
</canvas>
<form id="selector">
<select id="image_select"></select>
<input type="submit"/>
</form>
<p id="result"></p>
</div>
<script src="edge.js"></script>
<script>
var image = new Image();
var images = [
'http://userserve-ak.last.fm/serve/252/254612.jpg',
'http://danyo.co.uk/stuff/bob.png',
'http://userserve-ak.last.fm/serve/252/3614801.jpg',
'http://userserve-ak.last.fm/serve/252/2162238.jpg',
'http://userserve-ak.last.fm/serve/252/47493919.png',
'http://farm5.static.flickr.com/4067/5126215174_f7c556c026_z.jpg',
'http://danyo.co.uk/edge/matt.png',
"http://danyo.co.uk/stuff/nicky.jpg",
'http://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/Broadway_tower_edit.jpg/274px-Broadway_tower_edit.jpg',
'http://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/Broadway_tower_edit.jpg/800px-Broadway_tower_edit.jpg',
'http://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/f07/proj2/www/wwedler/gateway_arch.jpg',
'http://3.bp.blogspot.com/_h79Be84WZ2U/TECykCpoj_I/AAAAAAAAAGc/Dy1Nw6gbWq8/s800/illaroja.jpg',
'http://danyo.co.uk/edge/gray.png',
'http://farm5.static.flickr.com/4108/5174249969_e3a468f4b6.jpg',
'http://farm5.static.flickr.com/4154/5061928555_e65ccd5bb5_z.jpg',
'http://farm5.static.flickr.com/4106/4952538434_48522092bd.jpg',
'http://farm5.static.flickr.com/4136/4952510646_8ae378f4ec.jpg',
'http://userserve-ak.last.fm/serve/252/314980.jpg',
'http://userserve-ak.last.fm/serve/252/52570.jpg'
];
var go = function (image) {
var start = (new Date()).getTime();
document.getElementById('candidate').src = image.src;
e = new Edge(image, 'test');
//console.profile('edge')
function goV() {
e.mapVertical();
}
function goH() {
e.mapHorizontal();
}
function goM () {
e.mapMagnitude();
}
function goSC () {
e.mapSeamCost();
}
//goH();
//goV();
e.map();
goM();
goSC();
//console.profileEnd();
var end = (new Date()).getTime();
e.context.putImageData(e.magnitudeData, 0,0);
document.getElementById('result').innerHTML = "Completed in " + ((end - start)/1000) + ' seconds';
}
var select = document.getElementById('image_select');
for (var i = 0; i < images.length; i++) {
var opt = document.createElement('option');
opt.text = images[i];
opt.value = images[i];
select.appendChild(opt);
}
document.getElementById('image_select').onchange = function () {
image.onload = function () {
go(image);
}
image.src = this.value;
return false;
}
</script>
</body>
</html>