-
Notifications
You must be signed in to change notification settings - Fork 3
/
rawimage.min.js
2 lines (2 loc) · 31.3 KB
/
rawimage.min.js
1
2
rawimage=function(){function rawimage(el,dimension){var canvasStyle,overlayStyle,parentStyle;this.el=el;this.width=this.height=dimension;this.reset();this.canvas=document.createElement("canvas");this.canvas.setAttribute("width",this.width);this.canvas.setAttribute("height",this.height);this.canvas.setAttribute("class","rawimage-visualization");this.overlay=document.createElement("canvas");this.overlay.setAttribute("width",this.width);this.overlay.setAttribute("height",this.height);this.overlay.setAttribute("class","rawimage-overlay");this.overlayCtx=this.overlay.getContext("2d");this.el.appendChild(this.canvas);this.el.appendChild(this.overlay);this.nTextures=1;this.lookup={};if(!this.getContext())return null;this.offsetLeft=this.canvas.offsetLeft;this.offsetTop=this.canvas.offsetTop;parentStyle=this.canvas.parentElement.style;parentStyle.width=""+this.canvas.width+"px";parentStyle.height=""+this.canvas.height+"px";parentStyle.overflow="hidden";parentStyle.backgroundColor="#252525";parentStyle.position="relative";canvasStyle=this.canvas.style;canvasStyle.position="absolute";overlayStyle=this.overlay.style;overlayStyle.position="absolute";overlayStyle.pointerEvents="none";this.xOffset=-this.width/2;this.yOffset=-this.height/2;this.xOldOffset=this.xOffset;this.yOldOffset=this.yOffset;this.drag=false;this.zoom=2/this.width;this.minZoom=this.zoom/8;this.maxZoom=20*this.zoom;this.zoomX=this.zoom;this.zoomY=this.zoom;this.crosshair=false}rawimage.prototype.reset=function(){this.programs={};this.uniforms={};this.textures={};this.buffers=[];this.shaders=[]};rawimage.prototype.destroy=function(){var item;for(item in this.textures){this.gl.deleteTexture(this.textures[item])}this.buffers.forEach(function(item){this.gl.deleteBuffer(item)},this);this.shaders.forEach(function(item){this.gl.deleteShader(item)},this);for(item in this.programs){this.gl.deleteProgram(this.programs[item])}this.gl=undefined;this.reset()};rawimage.shaders={vertex:["attribute vec2 aPosition;","attribute vec2 aTextureCoordinate;","uniform vec2 uOffset;","uniform float uScale;","varying vec2 vTextureCoordinate;","void main() {","vec2 position = aPosition + uOffset;","position = position * uScale;","gl_Position = vec4(position, 0.0, 1.0);","vTextureCoordinate = aTextureCoordinate;","}"].join(""),linear:["precision mediump float;","uniform sampler2D uTexture0;","uniform sampler2D uColorMap;","uniform float uColorIndex;","uniform vec2 uExtent;","varying vec2 vTextureCoordinate;","void main() {","vec4 pixel_v = texture2D(uTexture0, vTextureCoordinate);","float min = uExtent[0];","float max = uExtent[1];","float x = (pixel_v.r - min) / (max - min);","gl_FragColor = texture2D( uColorMap, vec2(x, uColorIndex / 70.0) );","}"].join(""),logarithm:["precision mediump float;","uniform sampler2D uTexture0;","uniform sampler2D uColorMap;","uniform float uColorIndex;","uniform vec2 uExtent;","varying vec2 vTextureCoordinate;","float logarithm(float value) {","return log(value / 0.05 + 1.0) / log(1.0 / 0.05 + 1.0);","}","void main() {","vec4 pixel_v = texture2D(uTexture0, vTextureCoordinate);","float min = uExtent[0];","float max = logarithm(uExtent[1] - min);","float logMin = logarithm(0.0);","float pixel = logarithm(pixel_v[0] - min);","float x = (pixel - logMin) / (max - logMin);","gl_FragColor = texture2D( uColorMap, vec2(x, uColorIndex / 70.0) );","}"].join(""),sqrt:["precision mediump float;","uniform sampler2D uTexture0;","uniform sampler2D uColorMap;","uniform float uColorIndex;","uniform vec2 uExtent;","varying vec2 vTextureCoordinate;","void main() {","vec4 pixel_v = texture2D(uTexture0, vTextureCoordinate);","float min = uExtent[0];","float max = uExtent[1] - min;","float x = sqrt( (pixel_v[0] - min) / max);","gl_FragColor = texture2D( uColorMap, vec2(x, uColorIndex / 70.0) );","}"].join(""),arcsinh:["precision mediump float;","uniform sampler2D uTexture0;","uniform sampler2D uColorMap;","uniform float uColorIndex;","uniform vec2 uExtent;","varying vec2 vTextureCoordinate;","float arcsinh(float value) {","return log(value + sqrt(1.0 + value * value));","}","void main() {","vec4 pixel_v = texture2D(uTexture0, vTextureCoordinate);","float min = 0.0;","float max = arcsinh( uExtent[1] - uExtent[0] );","float x = arcsinh( pixel_v[0] - uExtent[0] ) / max;","gl_FragColor = texture2D( uColorMap, vec2(x, uColorIndex / 70.0) );","}"].join(""),power:["precision mediump float;","uniform sampler2D uTexture0;","uniform sampler2D uColorMap;","uniform float uColorIndex;","uniform vec2 uExtent;","varying vec2 vTextureCoordinate;","void main() {","vec4 pixel_v = texture2D(uTexture0, vTextureCoordinate);","float min = uExtent[0];","float max = pow(uExtent[1] - min, 2.0);","float pixel = pow(pixel_v[0] - min, 2.0);","float x = pixel / max;","gl_FragColor = texture2D( uColorMap, vec2(x, uColorIndex / 70.0) );","}"].join(""),color:["precision mediump float;","uniform sampler2D uTexture0;","uniform sampler2D uTexture1;","uniform sampler2D uTexture2;","uniform float uScaleR;","uniform float uScaleG;","uniform float uScaleB;","uniform float uCalibrationR;","uniform float uCalibrationG;","uniform float uCalibrationB;","uniform float uAlpha;","uniform float uQ;","varying vec2 vTextureCoordinate;","float arcsinh(float value) {","return log(value + sqrt(1.0 + value * value));","}","void main() {","vec4 pixel_v_r = texture2D(uTexture0, vTextureCoordinate);","vec4 pixel_v_g = texture2D(uTexture1, vTextureCoordinate);","vec4 pixel_v_b = texture2D(uTexture2, vTextureCoordinate);","float r = (pixel_v_r[0]) * uCalibrationR * uScaleR;","float g = (pixel_v_g[0]) * uCalibrationG * uScaleG;","float b = (pixel_v_b[0]) * uCalibrationB * uScaleB;","float I = r + g + b + 1e-10;","float factor = arcsinh(uAlpha * uQ * I) / (uQ * I);","float R = clamp(r * factor, 0.0, 1.0);","float G = clamp(g * factor, 0.0, 1.0);","float B = clamp(b * factor, 0.0, 1.0);","gl_FragColor = vec4(R, G, B, 1.0);","}"].join("")};rawimage.prototype.loadColorMap=function(){var img,target=this;this.setRectangle(256,70);img=new Image;img.onload=function(){var texture,name,program,uColorMap;target.gl.activeTexture(target.gl.TEXTURE0);texture=target.gl.createTexture();target.gl.bindTexture(target.gl.TEXTURE_2D,texture);target.gl.texParameteri(target.gl.TEXTURE_2D,target.gl.TEXTURE_WRAP_S,target.gl.CLAMP_TO_EDGE);target.gl.texParameteri(target.gl.TEXTURE_2D,target.gl.TEXTURE_WRAP_T,target.gl.CLAMP_TO_EDGE);target.gl.texParameteri(target.gl.TEXTURE_2D,target.gl.TEXTURE_MIN_FILTER,target.gl.NEAREST);target.gl.texParameteri(target.gl.TEXTURE_2D,target.gl.TEXTURE_MAG_FILTER,target.gl.NEAREST);target.gl.texImage2D(target.gl.TEXTURE_2D,0,target.gl.RGB,target.gl.RGB,target.gl.UNSIGNED_BYTE,img);for(name in target.programs){if(name==="color")continue;program=target.programs[name];target.gl.useProgram(program);uColorMap=target.uniforms[name].uColorMap;target.gl.uniform1i(uColorMap,0)}target.gl.useProgram(target.programs[target.program]);target.gl.drawArrays(target.gl.TRIANGLES,0,6)};img.src="data:image/png;base64,"+rawimage.colormaps.base64};rawimage.colormaps={base64:"iVBORw0KGgoAAAANSUhEUgAAAQAAAABGCAYAAAAjBEqjAAAmjklEQVR4nO19f8wmV3Xec+7M++3am7hQtw4BYydOWGMwrJeWBggJpRBTUqFECiqtqFCE5KRIqYqKFCT+IFCJCEVRkYrEH0j8gUQkpFRChQrJ1FFoqUwD2LsL2MEh/AimbqDYxvba3+77ztynf9xz7z33zp33x+dd75L9vk9X55znPOfcmXln7ty5c2dGwPcRBEIRLZeTXcuflPpreVj/Yf2XX/1Ckn4c4b1HkCP86FUafMJZ59sm/vKog97DdQ6uEzgn62WBuTW+uXh3kevYfT0ogoEsC3DFYGQP+CPAuAiSC2DcA7wWRt9eu9DE+gXAvTLe7wG+h/MeMo6Qcby8dPJ3SJpGgVouJ7uW28bX8rD+w/qvpPq3sIUEc9fgsByWw3Illf6ee74C/PjHu5WzT8ABEC3b6p2WbXW5CsBP7Vj63Yt3ALtQttFHBwyiZUv9LIDHADyuchsdIwCv8nLScRSQY4C7Osht9K1/ecm67wFq2Up3u6/LOQD7AJ5SuY0eLiS2Lh1GXA2PYyCOgVvpPTyo/35L/TzOYR9P4ik8hX08uZUu7wPo9CdYV+LP8nfNLyJA31+xx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nBu:38,YlGn:37,YlOrBr:36,YlOrRd:35,afmhot:34,autumn:33,binary:32,bone:31,brg:30,bwr:29,cool:28,coolwarm:27,copper:26,cubehelix:25,flag:24,gist_earth:23,gist_gray:22,gist_heat:21,gist_ncar:20,gistainbow:19,gist_stern:18,gist_yarg:17,gnuplot2:16,gnuplot:15,gray:14,hot:13,hsv:12,jet:11,ocean:10,pink:9,prism:8,rainbow:7,seismic:6,spectral:5,spring:4,summer:3,terrain:2,winter:1};rawimage.prototype.setupControls=function(callbacks,opts){var voidfn,onmousedown,onmousemove,onmouseout,onmouseover,onmouseup,target=this;voidfn=function(){void 0};callbacks=callbacks===undefined?{}:callbacks;callbacks.onmousedown=callbacks.onmousedown||voidfn;callbacks.onmouseup=callbacks.onmouseup||voidfn;callbacks.onmousemove=callbacks.onmousemove||voidfn;callbacks.onmouseout=callbacks.onmouseout||voidfn;callbacks.onmouseover=callbacks.onmouseover||voidfn;callbacks.onzoom=callbacks.onzoom||voidfn;this.canvas.onmousedown=function(e){target.drag=true;target.xOldOffset=target.xOffset;target.yOldOffset=target.yOffset;target.xMouseDown=e.clientX;target.yMouseDown=e.clientY;callbacks.onmousedown.call(target,opts,e)};this.canvas.onmouseup=function(e){var dx,dy;target.drag=false;if(target.xMouseDown===null)return;dx=e.clientX-target.xMouseDown;dy=e.clientY-target.yMouseDown;target.xOffset=target.xOldOffset+dx/target.width/target.zoom*2;target.yOffset=target.yOldOffset-dy/target.height/target.zoom*2;target.draw();callbacks.onmouseup.call(target,opts,e)};this.canvas.onmousemove=function(e){var dx,dy,xOffset,yOffset,x,y;if(target.crosshair){target.xCurrent=e.layerX;target.yCurrent=e.layerY;target.drawCrosshair()}if(target.drag){dx=e.clientX-target.xMouseDown;dy=e.clientY-target.yMouseDown;target.xOffset=target.xOldOffset+dx/target.width/target.zoom*2;target.yOffset=target.yOldOffset-dy/target.height/target.zoom*2;target.draw()}xOffset=e.clientX-target.offsetLeft;yOffset=e.clientY-target.offsetTop;dx=-1*(target.width/2-xOffset)/target.width/target.zoom*2;dy=(target.height/2-yOffset)/target.height/target.zoom*2;x=-1*(target.xOffset+.5)+dx+1.5<<0;y=-1*(target.yOffset+.5)+dy+1.5<<0;callbacks.onmousemove.call(target,x,y,opts,e)};this.canvas.onmouseout=function(e){target.drag=false;callbacks.onmouseout.call(target,opts,e)};this.canvas.onmouseover=function(e){target.drag=false;callbacks.onmouseover.call(target,opts,e)};onzoom=function(e){var factor,uScale;e.preventDefault();factor=e.shiftKey?1.01:1.1;target.zoom*=(e.wheelDelta||e.deltaY)<0?1/factor:factor;target.zoom=target.zoom>target.maxZoom?target.maxZoom:target.zoom;target.zoom=target.zoom<target.minZoom?target.minZoom:target.zoom;target.draw();callbacks.onzoom()};this.canvas.addEventListener("mousewheel",onzoom,false);this.canvas.addEventListener("wheel",onzoom,false)};rawimage.prototype.setCursor=function(){this.overlay.width=this.overlay.width;this.crosshair=type==="crosshair"?true:false};rawimage.prototype.drawCrosshair=function(){this.overlay.width=this.overlay.width;this.overlayCtx.lineWidth=1;this.overlayCtx.strokeStyle="#0071e5";this.overlayCtx.moveTo(0,this.yCurrent);this.overlayCtx.lineTo(this.width,this.yCurrent);this.overlayCtx.moveTo(this.xCurrent,0);this.overlayCtx.lineTo(this.xCurrent,this.height);this.overlayCtx.stroke()};rawimage.prototype.fragmentShaders=["linear","logarithm","sqrt","arcsinh","power","color"];rawimage.prototype.getExtension=function(){return this.gl.getExtension("OES_texture_float")};rawimage.prototype.loadShader=function(source,type){var gl,shader,compiled,error;gl=this.gl;shader=gl.createShader(type);gl.shaderSource(shader,source);gl.compileShader(shader);compiled=gl.getShaderParameter(shader,gl.COMPILE_STATUS);if(!compiled){gl.deleteShader(shader);error=gl.getShaderInfoLog(shader);throw"Error compiling shader "+shader+": "+error;return null}this.shaders.push(shader);return shader};rawimage.prototype.createProgram=function(vertexShader,fragmentShader){var gl,linked,program;gl=this.gl;program=gl.createProgram();gl.attachShader(program,vertexShader);gl.attachShader(program,fragmentShader);gl.linkProgram(program);linked=gl.getProgramParameter(program,gl.LINK_STATUS);if(!linked){gl.deleteProgram(program);throw"Error in program linking: "+gl.getProgramInfoLog(program);return null}return program};rawimage.prototype.setRectangle=function(width,height){var x1,x2,y1,y2;x1=0,x2=width;y1=0,y2=height;this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([x1,y1,x2,y1,x1,y2,x1,y2,x2,y1,x2,y2]),this.gl.STATIC_DRAW)};rawimage.prototype.updateUniforms=function(){var uniforms=this.uniforms[this.program];this.gl.uniform2f(uniforms.uOffset,this.xOffset,this.yOffset);this.gl.uniform1f(uniforms.uScale,this.zoom)};rawimage.prototype.getContext=function(){var width,height,ext,vertexShader,fragmentShader,key,i,program,buffer;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl");if(!this.gl)return false;width=this.width;height=this.height;this.gl.viewport(0,0,width,height);ext=this.getExtension();if(!ext)return false;vertexShader=this.loadShader(rawimage.shaders.vertex,this.gl.VERTEX_SHADER);if(!vertexShader)return false;this.fragmentShaders.forEach(function(key){fragmentShader=this.loadShader(rawimage.shaders[key],this.gl.FRAGMENT_SHADER);if(!fragmentShader)return false;program=this.createProgram(vertexShader,fragmentShader);if(!program)return false;this.programs[key]=program;this.gl.useProgram(program);this.uniforms[key]={};["uOffset","uScale","uExtent","uColorIndex","uColorMap","uTexture0"].forEach(function(u){this.uniforms[key][u]=this.gl.getUniformLocation(program,u)},this);this.gl.uniform2f(this.uniforms[key].uOffset,-width/2,-height/2);this.gl.uniform1f(this.uniforms[key].uScale,2/width);this.gl.uniform1f(this.uniforms[key].uColorIndex,rawimage.colormaps.binary-.5);this.gl.uniform1i(this.uniforms[key].uTexture0,1)},this);["uScaleR","uScaleG","uScaleB","uCalibrationR","uCalibrationG","uCalibrationB","uAlpha","uQ","uTexture1","uTexture2"].forEach(function(key){this.uniforms["color"][key]=this.gl.getUniformLocation(program,key)},this);this.aPosition=this.gl.getAttribLocation(program,"aPosition");this.aTextureCoordinate=this.gl.getAttribLocation(program,"aTextureCoordinate");this.program="linear";this.gl.useProgram(this.programs[this.program]);buffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,buffer);this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),this.gl.STATIC_DRAW);this.gl.enableVertexAttribArray(this.aTextureCoordinate);this.gl.vertexAttribPointer(this.aTextureCoordinate,2,this.gl.FLOAT,false,0,0);this.buffers.push(buffer);buffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,buffer);this.gl.enableVertexAttribArray(this.aPosition);this.gl.vertexAttribPointer(this.aPosition,2,this.gl.FLOAT,false,0,0);this.buffers.push(buffer);this.loadColorMap();this.currentImage=null;this.MAX_TEXTURE_SIZE=this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE);return true};rawimage.prototype.draw=function(){this.updateUniforms();this.gl.drawArrays(this.gl.TRIANGLES,0,6)};rawimage.prototype.loadImage=function(id,arr,width,height){var index,texture,factor,downsampled;var dimension=width>height?width:height;if(dimension>this.MAX_TEXTURE_SIZE){factor=~~(dimension/this.MAX_TEXTURE_SIZE)+1;downsampled=this.downsample(arr,width,height,factor);arr=downsampled.arr,width=downsampled.width,height=downsampled.height}if(this.lookup.hasOwnProperty(id)){index=this.lookup[id];this.gl.activeTexture(this.gl.TEXTURE0+index);if(arr.constructor!==Float32Array){arr=new Float32Array(arr)}this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.LUMINANCE,width,height,0,this.gl.LUMINANCE,this.gl.FLOAT,arr);return}this.setRectangle(width,height);index=this.nTextures;this.lookup[id]=this.nTextures;this.gl.activeTexture(this.gl.TEXTURE0+index);texture=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_2D,texture);this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE);this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE);this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST);this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST);if(arr.constructor!==Float32Array){arr=new Float32Array(arr)}this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.LUMINANCE,width,height,0,this.gl.LUMINANCE,this.gl.FLOAT,arr);this.currentImage=this.currentImage||id;this.textures[id]=texture;this.nTextures+=1};rawimage.prototype.setColorMap=function(cmap){var cmaps,index,name,program,uColorIndex;cmaps=Object.keys(rawimage.colormaps);index=cmaps.indexOf("base64");cmaps.splice(index,1);cmap=cmaps.indexOf(cmap)>-1?cmap:"binary";for(name in this.programs){if(name==="color")continue;program=this.programs[name];this.gl.useProgram(program);uColorIndex=this.uniforms[name].uColorIndex;this.gl.uniform1f(uColorIndex,rawimage.colormaps[cmap]-.5)}this.gl.useProgram(this.programs[this.program]);this.gl.drawArrays(this.gl.TRIANGLES,0,6)};rawimage.prototype.setImage=function(id){var index=this.lookup[id];this.gl.activeTexture(this.gl.TEXTURE0+index);this.gl.uniform1i(this.uniforms[this.program].uTexture0,index);this.currentImage=id};rawimage.prototype.setExtent=function(min,max){var name,program,uExtent;for(name in this.programs){if(name==="color")continue;program=this.programs[name];this.gl.useProgram(program);uExtent=this.uniforms[name].uExtent;this.gl.uniform2f(uExtent,min,max)}this.gl.useProgram(this.programs[this.program]);this.gl.drawArrays(this.gl.TRIANGLES,0,6)};rawimage.prototype.downsample=function(arr,width,height,factor){var i,j,ii,jj,newWidth,newHeight,sum,N;newWidth=parseInt((width+factor-1)/factor);newHeight=parseInt((height+factor-1)/factor);newArr=new arr.constructor(newWidth*newHeight);for(j=0;j<newHeight;j+=1){for(i=0;i<newWidth;i+=1){sum=0,N=0;for(jj=0;jj<factor;jj+=1){if(j*factor+jj>=height)break;for(ii=0;ii<factor;ii+=1){if(i*factor+ii>=width)break;sum+=arr[(j*factor+jj)*width+(i*factor+ii)];N+=1}}newArr[j*newWidth+i]=sum/N}}return{arr:newArr,width:newWidth,height:newHeight}};rawimage.prototype.setStretch=function(stretch){this.program=stretch;this.gl.useProgram(this.programs[stretch]);this.draw()};rawimage.prototype.setScales=function(r,g,b){var color;this.gl.useProgram(this.programs.color);color=this.uniforms.color;this.gl.uniform1f(color.uScaleR,r);this.gl.uniform1f(color.uScaleG,g);this.gl.uniform1f(color.uScaleB,b);this.gl.drawArrays(this.gl.TRIANGLES,0,6)};rawimage.prototype.setCalibrations=function(r,g,b){var color;this.gl.useProgram(this.programs.color);color=this.uniforms.color;this.gl.uniform1f(color.uCalibrationR,r);this.gl.uniform1f(color.uCalibrationG,g);this.gl.uniform1f(color.uCalibrationB,b);this.gl.drawArrays(this.gl.TRIANGLES,0,6)};rawimage.prototype.setAlpha=function(alpha){this.gl.useProgram(this.programs.color);this.gl.uniform1f(this.uniforms.color.uAlpha,alpha);this.gl.drawArrays(this.gl.TRIANGLES,0,6)};rawimage.prototype.setQ=function(Q){this.gl.useProgram(this.programs.color);this.gl.uniform1f(this.uniforms.color.uQ,Q);this.gl.drawArrays(this.gl.TRIANGLES,0,6)};rawimage.prototype.drawColor=function(rId,gId,bId){this.gl.clear(this.gl.COLOR_BUFFER_BIT);this.program="color";this.gl.useProgram(this.programs.color);this.gl.uniform1i(this.uniforms.color.uTexture0,this.lookup[rId]);this.gl.uniform1i(this.uniforms.color.uTexture1,this.lookup[gId]);this.gl.uniform1i(this.uniforms.color.uTexture2,this.lookup[bId]);
this.draw()};rawimage.version="0.5.3";return rawimage}();