forked from bolidozor/js9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs9blend.html
executable file
·179 lines (168 loc) · 6.38 KB
/
js9blend.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
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
173
174
175
176
177
178
179
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" >
<link type="image/x-icon" rel="shortcut icon" href="./favicon.ico">
<link type="text/css" rel="stylesheet" href="js9support.css">
<link type="text/css" rel="stylesheet" href="js9.css">
<script type="text/javascript" src="js9support.min.js"></script>
<script type="text/javascript" src="js9.min.js"></script>
<script type="text/javascript" src="js9plugins.js"></script>
<title>JS9 blend</title>
</head>
<body onload="javascript:init()">
<center><font size="+1"><b>JS9 Demo: image blending</b></font></center>
<table cellspacing="20">
<tr>
<td style="vertical-align:top">
<div class="JS9Menubar"></div>
<div class="JS9"></div>
<div style="margin-top: 2px;">
<div class="JS9Colorbar"></div>
</div>
</td>
<td style="vertical-align:top">
<div class="JS9Blend"></div>
<p>
Step 1: Load two or more images (chandra and spitzer are good to start with).
<p>
<input type="button" id="chandra" value="chandra" onclick="javascript:loadim('chandra')">
<input type="button" id="spitzer" value="spitzer" onclick="javascript:loadim('spitzer')">
<input type="button" id="galex" value="galex" onclick="javascript:loadim('galex')">
<p>
Step 2: Choose the <b>WCS->reproject</b> menu option to align the images (using
<br>
the Montage/mProjectPP program from IPAC).
<p>
Step 3: Adjust scale, contrast, bias, colormap for each image, as usual ...
<br>
or click below to set a demo-ready contrast/bias for each image.
<p>
<input type="button" id="cb" value="nice contrast/bias" onclick="javascript:xcb()">
<p>
Step 4: Use the <b>Image Blending plugin</b> above to choose a blend mode/opacity
<br>
for your images ('screen' is good) and activate blending for each one.
<p>
Step 5: If necessary, turn on <b>Image Blending</b>. You can toggle the blending
<br>
of individual images, or change their colormaps, scales, contrast/bias ...
</td>
</tr>
</table>
<script type="text/javascript">
var blendMode = false;
var ropts = {};
var xdir = "./blend/";
var images = ["galex.fits", "chandra.fits", "spitzer.fits"];
var cmaps = ["green", "red", "blue"];
var scales = ["log", "log", "log"];
var blends = ["screen", "screen", "screen"];
var opacities = [0.8, 0.8, 0.8];
var scalemin = [0, 0, 0];
var scalemax = [0, 0, 0];
var contrast = [4.1, 5.9, 6.6];
var bias = [0.25, 0.13, 0.56];
var loaded = [false, false, false, false];
var reprojed = [false, false, false, false];
var sigma = 1;
function init(){
$('#blur').prop('selectedIndex', 0);
$('#blend').prop('selectedIndex', 0);
$('#opacity').prop('selectedIndex', 0);
}
function loadim(s){
var idx = -1;
var file = s + ".fits";
for(i=0; i<images.length; i++){
if( images[i] === file ){
idx = i;
break;
}
}
console.log("loading: %s", file)
opts = {colormap: cmaps[idx], scale: scales[idx],
onload: function(im){
loaded[idx] = im;
}}
if( scalemin[idx] || scalemax[idx] ){
opts.scalemin = scalemin[idx];
opts.scalemax = scalemax[idx];
}
JS9.Load(xdir+file, opts);
}
function reproject(){
var im = JS9.GetImage();
for(i=0; i<loaded.length; i++){
if( loaded[i] && (loaded[i] !== im) && (reprojed[i] === false) ){
console.log("reprojecting %d: %s using %s", i, loaded[i], im.id);
loaded[i].reprojectData(im, ropts);
reprojed[i] = true;
}
}
}
function xblur(target){
var im = JS9.GetImage();
var sigma = target.options[target.selectedIndex].value;
if( im && sigma !== "" ){
console.log("blur: %s %s", im.id, sigma);
im.gaussBlurData(parseFloat(sigma));
}
}
function xcb(){
var i;
var im = JS9.GetImage();
for(i=0; i<loaded.length; i++){
if( loaded[i] && (loaded[i] === im) ){
if( contrast[i] && bias[i] ){
console.log("contrast/bias [%s,%s] for %s",
contrast[i], bias[i], im.id);
im.setColormap(contrast[i], bias[i]);
}
}
}
}
function xblend(target){
var im = JS9.GetImage();
var blend = target.options[target.selectedIndex].value;
if( im && blend !== "" ){
im.blendImage(blend);
}
}
function xopacity(target){
var im = JS9.GetImage();
var opacity = target.options[target.selectedIndex].value;
if( im && opacity !== "" ){
im.blendImage(null, opacity);
}
}
function toggle(){
blendMode = !blendMode;
JS9.BlendDisplay(blendMode);
$("#blendstr").html(blendMode ? "<b>on<\/b>" : "<b>off<\/b>");
}
</script>
<p>
JS9 Demos:
<ul>
<li><a href='js9basics.html'>JS9 Demo: the basics</a>
<li><a href='js9bespoke.html'>JS9 Demo: web page control of JS9</a>
<li><a href='js9sizes.html'>JS9 Demo: setting the size of the JS9 display</a>
<li><a href='js9plugins.html'>JS9 Demo: adding plugins to JS9</a>
<li><a href='js9imexam.html'>JS9 Demo: the imexam plugin for JS9</a>
<li><a href='js9blend.html'>JS9 Demo: image blending</a>
<li><a href='js9cat.html'>JS9 Demo: overlaying catalogs</a>
<li><a href='js9panzoom.html'>JS9 Demo: pan and zoom</a>
<li><a href='js9rgb.html'>JS9 Demo: RGB composite images</a>
<li><a href='js9multi.html'>JS9 Demo: independent instances of JS9</a>
<li><a href='js9analysis.html'>JS9 Demo: remote data analysis</a>
<li><a href='js9onchange.html'>JS9 Demo: running tasks when a region changes</a>
<li><a href='js9create.html'>JS9 Demo: creating a JS9 instance dynamically</a>
<li><a href='js9preload.html'>JS9 Demo: preloading images into JS9</a>
<li><a href='js9bitpix.html'>JS9 Demo: displaying different FITS datatypes</a>
<li><a href='js9pngvsfits.html'>JS9 Demo: PNG representation files vs FITS files</a>
</ul>
</body>
</html>