You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: can compress image data before sending it to over the websocket
This is useful when the widget is being used over a non-local network.
This can reduce the network traffic by a factor of 80 (for smooth, easy
to compress images). Pure noise image (random pixels) will not compress
well but will still see a factor of 7 reduction in size,
due to using uint8 instead of float64.
@@ -114,6 +144,10 @@ class ImageGLView extends bqplot.Mark {
114
144
// basically the corners of the image
115
145
image_domain_x : {type: "2f",value: [0.0,1.0]},
116
146
image_domain_y : {type: "2f",value: [0.0,1.0]},
147
+
// in the case we use an image for the values, the image is normalized, and we need to scale
148
+
// it back to a particular image range
149
+
// This needs to be set to [0, 1] for array data (which is not normalized)
150
+
range_image : {type: "2f",value: [0.0,1.0]},
117
151
// extra opacity value
118
152
opacity: {type: 'f',value: 1.0}
119
153
},
@@ -280,39 +314,56 @@ class ImageGLView extends bqplot.Mark {
280
314
update_image(skip_render){
281
315
varimage=this.model.get("image");
282
316
vartype=null;
283
-
vardata=image.data;
284
-
if(datainstanceofUint8Array){
285
-
type=THREE.UnsignedByteType;
286
-
}elseif(datainstanceofFloat64Array){
287
-
console.warn('ImageGLView.data is a Float64Array which WebGL does not support, will convert to a Float32Array (consider sending float32 data for better performance).');
288
-
data=Float32Array.from(data);
289
-
type=THREE.FloatType;
290
-
}elseif(datainstanceofFloat32Array){
291
-
type=THREE.FloatType;
292
-
}else{
293
-
console.error('only types uint8 and float32 are supported');
console.warn('ImageGLView.data is a Float64Array which WebGL does not support, will convert to a Float32Array (consider sending float32 data for better performance).');
338
+
data=Float32Array.from(data);
339
+
type=THREE.FloatType;
340
+
}elseif(datainstanceofFloat32Array){
341
+
type=THREE.FloatType;
342
+
}else{
343
+
console.error('only types uint8 and float32 are supported');
0 commit comments