片段着色器 - 确定整个(单色)图像的最小/最大值并使用它们进行进一步的像素操作

2024-02-04

我想正常化单色图像像素以这种方式最小值为黑色,最大值为白色,并且两者之间的值按比例分布。 目前我在 canvas 中分两步完成,但我相信在 WebGL 中应该更快。

我可以想象通过片段着色器操纵颜色,但我找不到任何有效的方法来(1)确定图像的实际范围,也找不到(2)将此信息传递给另一个片段着色器的方法,然后该片段可以执行该灰色水平标准化。


似乎您可以在片段着色器中生成逐渐较小的纹理,并在每个纹理中写出最小值和最大值。例如,如果您有一个 16x16 纹理,那么对于每 2x2 像素写出 1 个代表最大值的像素。

 vec4 c00 = texture2D(sampler, uv);
 vec4 c10 = texture2D(sampler, uv + vec2(onePixelRight, 0));
 vec4 c01 = texture2D(sampler, uv + vec2(0, onePixelUp));
 vec4 c11 = texture2D(sampler, uv + vec2(onePixelRight, onePixelUp);
 gl_FragColor = max(max(c00, c10), max(c01, c11));

重复直到达到 1x1 像素。做同样的事情分钟。完成后,您将拥有 2 个 1x1 像素纹理。使用 readPixels 读取它们或将它们传递给另一个着色器作为您的范围。

使用更大的块可能会更快,而不是 2x2,使用 8x8 或 16x16 区域,但不断减少,直到达到 1x1 像素

在伪代码中。

// setup
textures = [];
framebuffers = [];
cellSize = 16
maxDimension = max(width, height)
w = width 
h = height
while w > 1 || h > 1
   w = max(1, w / cellSize)
   h = max(1, h / cellSize)
   textures.push(create Texture of size w, h)
   framebuffers.push(create framebuffer and attach texture)
}
  
// computation
bind original image as input texture
foreach(framebuffer)
   bind framebuffer
   render to framebuffer with max GLSL shader above
   bind texture of current framebuffer as input to next iteration
}

现在最后一个帧缓冲区为 1x1 像素纹理,其中包含最大值。

"use strict";

var cellSize = 2;

// make a texture as our source
var ctx = document.createElement("canvas").getContext("2d");
ctx.fillStyle = "rgb(12, 34, 56)";
ctx.fillRect(20, 30, 1, 1);
ctx.fillStyle = "rgb(254, 243, 232)";
ctx.fillRect(270, 140, 1, 1);

var canvas = document.createElement("canvas");
var m4 = twgl.m4;
var gl = canvas.getContext("webgl");
var fsSrc = document.getElementById("max-fs").text.replace("$(cellSize)s", cellSize);
var programInfo = twgl.createProgramInfo(gl, ["vs", fsSrc]);

var unitQuadBufferInfo = twgl.primitives.createXYQuadBufferInfo(gl);
var framebufferInfo = twgl.createFramebufferInfo(gl);

var srcTex = twgl.createTexture(gl, { 
  src: ctx.canvas, 
  min: gl.NEAREST, 
  mag: gl.NEAREST,
  wrap: gl.CLAMP_TO_EDGE,
});

var framebuffers = [];
var w = ctx.canvas.width;
var h = ctx.canvas.height;
while (w > 1 || h > 1) {
  w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
  h = Math.max(1, (h + cellSize - 1) / cellSize | 0);
  // creates a framebuffer and creates and attaches an RGBA/UNSIGNED texture 
  var fb = twgl.createFramebufferInfo(gl, [
    { min: gl.NEAREST, max: gl.NEAREST, wrap: gl.CLAMP_TO_EDGE },
  ], w, h);
  framebuffers.push(fb);
}

var uniforms = {
  u_srcResolution: [ctx.canvas.width, ctx.canvas.height],
  u_texture: srcTex,
};

gl.useProgram(programInfo.program);
twgl.setBuffersAndAttributes(gl, programInfo, unitQuadBufferInfo);

var w = ctx.canvas.width;
var h = ctx.canvas.height;
framebuffers.forEach(function(fbi, ndx) {
  w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
  h = Math.max(1, (h + cellSize - 1) / cellSize | 0);
  uniforms.u_dstResolution = [w, h];
  twgl.bindFramebufferInfo(gl, fbi);
  twgl.setUniforms(programInfo, uniforms);
  twgl.drawBufferInfo(gl, unitQuadBufferInfo);
  
  uniforms.u_texture = fbi.attachments[0];
  uniforms.u_srcResolution = [w, h];
});

var p = new Uint8Array(4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, p);
log("max: ", p[0], p[1], p[2]);


function log() {
  var elem = document.createElement("pre");
  elem.appendChild(document.createTextNode(Array.prototype.join.call(arguments, " ")));
  document.body.appendChild(elem);
}
<script id="vs" type="not-js">
attribute vec4 position;

void main() {
  gl_Position = position;
}
</script>
<script id="max-fs" type="not-js">
precision mediump float;

#define CELL_SIZE $(cellSize)s

uniform sampler2D u_texture;
uniform vec2 u_srcResolution;  
uniform vec2 u_dstResolution;  

void main() {
  // compute the first pixel the source cell
  vec2 srcPixel = floor(gl_FragCoord.xy) * float(CELL_SIZE);
  
  // one pixel in source
  vec2 onePixel = vec2(1) / u_srcResolution;
  
  // uv for first pixel in cell. +0.5 for center of pixel
  vec2 uv = (srcPixel + 0.5) * onePixel;
    
  vec4 maxColor = vec4(0);
  for (int y = 0; y < CELL_SIZE; ++y) {
    for (int x = 0; x < CELL_SIZE; ++x) {
      maxColor = max(maxColor, texture2D(u_texture, uv + vec2(x, y) * onePixel)); 
    }
  }

  gl_FragColor = maxColor;
}
</script>
<script src="https://twgljs.org/dist/4.x/twgl-full.min.js"></script>

另外如果你有WEBGL_draw_buffers支持您同时写入 2 个不同的帧缓冲区附件

"use strict";

var cellSize = 2;

// make a texture as our source
var ctx = document.createElement("canvas").getContext("2d");
ctx.fillStyle = "rgb(128, 128, 128)";
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.fillStyle = "rgb(12, 34, 56)";
ctx.fillRect(20, 30, 1, 1);
ctx.fillStyle = "rgb(254, 243, 232)";
ctx.fillRect(270, 140, 1, 1);

var canvas = document.createElement("canvas");
var m4 = twgl.m4;
var gl = canvas.getContext("webgl");

var ext = gl.getExtension("WEBGL_draw_buffers");
if (!ext) {
   alert("sample requires WEBGL_draw_buffers");
}
var fsSrc = document.querySelector("#minmax-fs").text.replace("$(cellSize)s", cellSize);
var programInfo = twgl.createProgramInfo(gl, ["vs", fsSrc]);

var unitQuadBufferInfo = twgl.primitives.createXYQuadBufferInfo(gl);

var srcTex = twgl.createTexture(gl, { 
  src: ctx.canvas, 
  min: gl.NEAREST, 
  mag: gl.NEAREST,
  wrap: gl.CLAMP_TO_EDGE,
});

var framebuffers = [];
var w = ctx.canvas.width;
var h = ctx.canvas.height;
while (w > 1 || h > 1) {
  w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
  h = Math.max(1, (h + cellSize - 1) / cellSize | 0);
  // creates a framebuffer and creates and attaches 2 RGBA/UNSIGNED textures
  var fbi = twgl.createFramebufferInfo(gl, [
    { min: gl.NEAREST, mag: gl.NEAREST, wrap: gl.CLAMP_TO_EDGE, },
    { min: gl.NEAREST, mag: gl.NEAREST, wrap: gl.CLAMP_TO_EDGE, },
  ], w, h);
  ext.drawBuffersWEBGL([ext.COLOR_ATTACHMENT0_WEBGL, ext.COLOR_ATTACHMENT1_WEBGL]);
  framebuffers.push(fbi);
}
    
// need separate FBs to read the output  
var lastFBI = framebuffers[framebuffers.length - 1];
var minFBI = twgl.createFramebufferInfo(gl, [
    { attachment: lastFBI.attachments[0] }
], 1, 1);
var maxFBI = twgl.createFramebufferInfo(gl, [
    { attachment: lastFBI.attachments[1] }
], 1, 1);

var uniforms = {
  u_srcResolution: [ctx.canvas.width, ctx.canvas.height],
  u_minTexture: srcTex,
  u_maxTexture: srcTex,
};

gl.useProgram(programInfo.program);
twgl.setBuffersAndAttributes(gl, programInfo, unitQuadBufferInfo);

var w = ctx.canvas.width;
var h = ctx.canvas.height;
framebuffers.forEach(function(fbi, ndx) {
  w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
  h = Math.max(1, (h + cellSize - 1) / cellSize | 0);
  uniforms.u_dstResolution = [w, h];
  twgl.bindFramebufferInfo(gl, fbi);
  twgl.setUniforms(programInfo, uniforms);
  twgl.drawBufferInfo(gl, unitQuadBufferInfo);
  
  uniforms.u_minTexture = fbi.attachments[0];
  uniforms.u_maxTexture = fbi.attachments[1];
  uniforms.u_srcResolution = [w, h];
});

var p = new Uint8Array(4);
twgl.bindFramebufferInfo(gl, minFBI);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, p);
log("min: ", p[0], p[1], p[2]);
twgl.bindFramebufferInfo(gl, maxFBI);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, p);
log("max: ", p[0], p[1], p[2]);

function log() {
  var elem = document.createElement("pre");
  elem.appendChild(document.createTextNode(Array.prototype.join.call(arguments, " ")));
  document.body.appendChild(elem);
}
<script id="vs" type="not-js">
attribute vec4 position;

void main() {
  gl_Position = position;
}
</script>
<script id="minmax-fs" type="not-js">
#extension GL_EXT_draw_buffers : require
precision mediump float;

#define CELL_SIZE $(cellSize)s

uniform sampler2D u_minTexture;
uniform sampler2D u_maxTexture;
uniform vec2 u_srcResolution;  
uniform vec2 u_dstResolution;  

void main() {
  // compute the first pixel the source cell
  vec2 srcPixel = floor(gl_FragCoord.xy) * float(CELL_SIZE);
  
  // one pixel in source
  vec2 onePixel = vec2(1) / u_srcResolution;
  
  // uv for first pixel in cell. +0.5 for center of pixel
  vec2 uv = (srcPixel + 0.5) / u_srcResolution;
    
  vec4 minColor = vec4(1);
  vec4 maxColor = vec4(0);
  for (int y = 0; y < CELL_SIZE; ++y) {
    for (int x = 0; x < CELL_SIZE; ++x) {
      vec2 off = uv + vec2(x, y) * onePixel;
      minColor = min(minColor, texture2D(u_minTexture, off));
      maxColor = max(maxColor, texture2D(u_maxTexture, off));
    }
  }

  gl_FragData[0] = minColor;
  gl_FragData[1] = maxColor;
}
</script>
<script src="https://twgljs.org/dist/4.x/twgl-full.min.js"></script>

现在您已经有了答案,您可以将其传递给另一个着色器来“对比”您的纹理

如果你读出这些值

uniform vec4 u_minColor;
uniform vec4 u_maxColor;
uniform sampler2D u_texture;

...

  vec4 color = texture2D(u_texture, uv);     
  vec4 range = u_maxColor - u_minColor;
  gl_FragColor = (color - u_minColor) * range;

如果您只想传递纹理而不读出它们,那么

uniform sampler2D u_minColor;
uniform sampler2D u_maxColor;
uniform sampler2D u_texture;

...
  vec4 minColor = texture2D(u_minColor, vec2(0));
  vec4 maxColor = texture2D(u_maxColor, vec2(0));
  vec4 color = texture2D(u_texture, uv);     
  vec4 range = maxColor - minColor;
  gl_FragColor = vec4(((color - minColor) / range).rgb, 1);

我不知道一个是否比另一个更好。我假设从纹理读取比从统一读取慢,但对于这么小的着色器,性能差异可能很小

"use strict";

var cellSize = 16;

var canvas = document.createElement("canvas");
var m4 = twgl.m4;
var gl = canvas.getContext("webgl");

var ext = gl.getExtension("WEBGL_draw_buffers");
if (!ext) {
   alert("sample requires WEBGL_draw_buffers");
}
var fsSrc = document.querySelector("#minmax-fs").text.replace("$(cellSize)s", cellSize);
var programInfo = twgl.createProgramInfo(gl, ["vs", fsSrc]);
var contrastProgramInfo = twgl.createProgramInfo(gl, ["vs", "contrastify-fs"]);

var unitQuadBufferInfo = twgl.primitives.createXYQuadBufferInfo(gl);

var srcTex = twgl.createTexture(gl, { 
  src: "http://i.imgur.com/rItAVSG.jpg",
  crossOrigin: "",
  min: gl.NEAREST, 
  mag: gl.NEAREST,
  wrap: gl.CLAMP_TO_EDGE,
}, function(err, srcTex, img) {
  img.style.width = "300px";
  img.style.height = "150px";
  log("before");
  document.body.appendChild(img);
  log("after");
  document.body.appendChild(canvas);
  var framebuffers = [];
  var w = img.width;
  var h = img.height;
  while (w > 1 || h > 1) {
    w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
    h = Math.max(1, (h + cellSize - 1) / cellSize | 0);
    // creates a framebuffer and creates and attaches 2 RGBA/UNSIGNED textures
    var fbi = twgl.createFramebufferInfo(gl, [
      { min: gl.NEAREST, mag: gl.NEAREST, wrap: gl.CLAMP_TO_EDGE, },
      { min: gl.NEAREST, mag: gl.NEAREST, wrap: gl.CLAMP_TO_EDGE, },
    ], w, h);
      ext.drawBuffersWEBGL([ext.COLOR_ATTACHMENT0_WEBGL, ext.COLOR_ATTACHMENT1_WEBGL]);
    framebuffers.push(fbi);
  }

  // need separate FBs to read the output  
  var lastFBI = framebuffers[framebuffers.length - 1];
  var minFBI = twgl.createFramebufferInfo(gl, [
    { attachment: lastFBI.attachments[0] }
  ], 1, 1);
  var maxFBI = twgl.createFramebufferInfo(gl, [
    { attachment: lastFBI.attachments[1] }
  ], 1, 1);

  var uniforms = {
    u_srcResolution: [img.width, img.height],
    u_minTexture: srcTex,
    u_maxTexture: srcTex,
  };

  gl.useProgram(programInfo.program);
  twgl.setBuffersAndAttributes(gl, programInfo, unitQuadBufferInfo);

  var w = img.width;
  var h = img.height;
  framebuffers.forEach(function(fbi, ndx) {
    w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
    h = Math.max(1, (h + cellSize - 1) / cellSize | 0);
    uniforms.u_dstResolution = [w, h];
    twgl.bindFramebufferInfo(gl, fbi);
    twgl.setUniforms(programInfo, uniforms);
    twgl.drawBufferInfo(gl, unitQuadBufferInfo);

    uniforms.u_minTexture = fbi.attachments[0];
    uniforms.u_maxTexture = fbi.attachments[1];
    uniforms.u_srcResolution = [w, h];
  });

  twgl.bindFramebufferInfo(gl, null);
  gl.useProgram(contrastProgramInfo.program);
  twgl.setUniforms(contrastProgramInfo, {
    u_resolution: [img.width, img.height],
    u_texture: srcTex,
    u_minColor: fbi.attachments[0],
    u_maxColor: fbi.attachments[1],
  });
  twgl.drawBufferInfo(gl, unitQuadBufferInfo);
});

function log() {
  var elem = document.createElement("pre");
  elem.appendChild(document.createTextNode(Array.prototype.join.call(arguments, " ")));
  document.body.appendChild(elem);
}
img, canvas { margin: 5px; border: 1px solid black; }
<script id="vs" type="not-js">
attribute vec4 position;

void main() {
  gl_Position = position;
}
</script>
<script id="minmax-fs" type="not-js">
#extension GL_EXT_draw_buffers : require
precision mediump float;

#define CELL_SIZE $(cellSize)s

uniform sampler2D u_minTexture;
uniform sampler2D u_maxTexture;
uniform vec2 u_srcResolution;  
uniform vec2 u_dstResolution;  

void main() {
  // compute the first pixel the source cell
  vec2 srcPixel = floor(gl_FragCoord.xy) * float(CELL_SIZE);
  
  // one pixel in source
  vec2 onePixel = vec2(1) / u_srcResolution;
  
  // uv for first pixel in cell. +0.5 for center of pixel
  vec2 uv = (srcPixel + 0.5) / u_srcResolution;
    
  vec4 minColor = vec4(1);
  vec4 maxColor = vec4(0);
  for (int y = 0; y < CELL_SIZE; ++y) {
    for (int x = 0; x < CELL_SIZE; ++x) {
      vec2 off = uv + vec2(x, y) * onePixel;
      minColor = min(minColor, texture2D(u_minTexture, off));
      maxColor = max(maxColor, texture2D(u_maxTexture, off));
    }
  }

  gl_FragData[0] = minColor;
  gl_FragData[1] = maxColor;
}
</script>
<script id="contrastify-fs" type="not-fs">
precision mediump float;
uniform sampler2D u_minColor;
uniform sampler2D u_maxColor;
uniform sampler2D u_texture;
uniform vec2 u_resolution;

void main() {
  vec2 uv = gl_FragCoord.xy / u_resolution;
  uv.y = 1.0 - uv.y;
  vec4 minColor = texture2D(u_minColor, vec2(0));
  vec4 maxColor = texture2D(u_maxColor, vec2(0));
  vec4 color = texture2D(u_texture, uv);     
  vec4 range = maxColor - minColor;
  gl_FragColor = vec4(((color - minColor) / range).rgb, 1);
}
</script>
<script src="https://twgljs.org/dist/4.x/twgl-full.min.js"></script>

至于单色只需将 src 纹理更改为gl.LUMINANCE

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

片段着色器 - 确定整个(单色)图像的最小/最大值并使用它们进行进一步的像素操作 的相关文章

  • 如何使用 HTML5 Canvas 作为 WebGL 纹理

    我想要 为情况 i 设置统一值 将案例 i 的计算着色器渲染为 HTML5
  • SignalR WebRTC WebSocket 已处于 CLOSING 或 CLOSED 状态

    我想测试运行 SignalR 和 WebRTC 的最简单实现 我将代码托管在https github com foyzulkarim WebRtc https github com foyzulkarim WebRtc 我制作了两个不同的文
  • HTML5 Canvas - 混合多个translate() 和scale() 调用

    我只是想知道 Canvas 转换是如何工作的 假设我有一个画布 在其内部某处绘制了一个圆圈 并且我想缩放该圆圈 因此它的中心点不会移动 所以我考虑做以下事情 translate circle x circle y scale factor
  • HTML5 将 png 缓冲区加载到画布中(用于流式传输)

    通过 websocket 我检索 PNG 格式的图像的二进制缓冲区 类似的东西 http blog nihilogic dk 2008 05 compression using canvas and png html 我想将此 PNG 缓冲
  • 如何使用 Fabric.js 在画布上画一条线

    我正在使用 Fabric js 在画布上画一条线 这是我的代码 但我没有得到任何输出 Line click function alert Line canvas add new fabric Line 50 100 200 200 left
  • 在 Three.js 中针对“子场景”进行光线投射

    因此 我正在使用 Three js 示例中的 webgl interactive cubes html 并且我有一个相对简单的问题 是否可以测试光线与对象的子对象的相交 例如 如果我做类似的事情 for var i 0 i lt 2000
  • WebGL 渲染抗锯齿

    我正在使用 webgl 和 javascript 有没有一种方法可以在不使用抗锯齿的情况下进行渲染 我需要每个像素都是纯色的 我当前的片段着色器非常简单 precision mediump float varying highp vec3
  • 如何在 Selenium 中的 HTML5 Canvas 上执行鼠标滚轮滚动?

    我正在开发 GWT 应用程序 类似于 Paint 在此 我有一个 HTML5 Canvas 其中有一个功能 向上和向下滚动鼠标滚轮将放大和缩小画布 我进行了很多搜索 但没有找到解决此问题的解决方法 这是所做的 int PosX 0 int
  • WebGL:Android 上对 OES_texture_float 的支持下降

    有谁知道减少对 WebGL 扩展的支持是怎么回事OES texture float多年来在Android上 https webglstats com webgl extension OES texture float platforms 0
  • 如何在 Three.js 中使用反射?

    我想在带有 Three js 的 WebGL 页面中拥有一个反射立方体表面 它应该类似于手机显示屏 反射一些光 但它仍然必须是黑色的 我创建了一个反射立方体 以及反射球体 的示例 并附有详细的注释 现场版本位于 http stemkoski
  • Paper.js:无法设置符号实例的 fillColor

    我是 paper js 的新手 对于这个项目 我需要一个将在许多实例中使用的形状 具有不同的填充颜色 因此显然使用符号更好 而不是使用 Path clone 方法 但是 一旦我将符号实例化为 PlacedSymbol 更改 fillColo
  • 如何计算 VU 仪表刻度的对数标签?

    我使用画布编写一个仪表小部件 需要计算刻度的标签值 没问题 除非我尝试重新创建 VU 表的刻度 我知道它是对数的 但在这种类型的仪表上 这些值不是 10 的幂 see https en wikipedia org wiki VU meter
  • HTML5 Canvas:绘制完成时获取事件

    我正在将图像绘制到画布元素 然后我就有了依赖于这个过程来完成的代码 我的代码如下所示 var myContext myCanvasElement getContext 2d myImg new Image myImg onload func
  • 保持文本在画布上垂直居中

    我遇到的问题是将用户输入的文本保持在画布元素内垂直居中 我已经构建了一个测试环境来尝试解决这个问题 我在这篇文章中提供了该环境以及小提琴 这是我的代码 HTML Enter Your Text br
  • 3D 图形矩阵 4x4 中最后一行的 magic 4 的用途是什么?

    当我阅读有关WebGL的书时 我看到了下一个矩阵描述 有关于书中最后一行的信息 WebGL 初学者指南 初学者指南 Diego Cantor Brandon Jones 神秘的第四排 第四排没有任何特殊之处 意义 元素 m4 m8 m12
  • 重复凹凸贴图

    我正在尝试使用 Three js r55 将凹凸贴图应用到平面上 以创建一个模糊的感觉表面 这是我的代码 var mapHeight THREE ImageUtils loadTexture images felt png mapHeigh
  • 在 Three.js 中渲染具有大量对象的多个场景的最佳方式

    想象一下 您想要绘制两个场景 每个场景都有数百个球体 并提供在这些场景之间切换的功能 做到这一点的最佳方法是什么 目前 一个开关大约需要 4 到 5 秒 因为我要删除 创建和绘制每个开关上的所有球体 下面是在场景切换上运行的代码示例 cle
  • 三.js Raycaster intersectObjects

    我正在尝试修改这个例子 https github com timoxley threejs blob master examples webgl morphtargets md2 control html来自 Three js 通过鼠标点击
  • 开始使用 Three.js 中的行进立方体

    我是 Three js 的新手 正在寻找教程来帮助我开始了解如何在 Three js 中使用 Marching Cubes 到目前为止 我在 Three js 中看到的一些使用它的项目对我来说有点复杂 所以一个简单的教程会很好 谢谢 像您一
  • webgl中绑定缓冲区的逻辑是什么?

    有时我发现自己在以不同顺序声明缓冲区 使用 createBuffer bindBuffer bufferdata 和在代码的其他部分 通常在绘制循环中 重新绑定它们之间挣扎 如果我在绘制数组之前不重新绑定顶点缓冲区 控制台会抱怨尝试访问超出

随机推荐

  • 如何从 CLI 调用 gnuplot 并将输出图形保存到图像文件?

    我正在编写一个批处理文件 该文件还将从 dat 文件生成 gnuplot 图 我希望使用我编写的 gnuplot gnu 脚本从命令行调用 gnuplot 并将输出图形保存到图像中 就像是 gnuplot exe script gnu gt
  • 有人知道 eclipse 的共享待办事项列表插件吗

    有谁知道 Eclipse 的共享 TODO 列表插件允许开发团队中的所有用户查看和编辑相同的任务列表 Mylyn http www eclipse org mylyn 可用于将问题跟踪系统集成到 IDE 中 它通过使任务成为 Eclipse
  • 使用 Macro_rules 中的可选数据表示枚举变体

    我正在尝试创建一个宏来帮助处理我一直在重复编写的一些样板枚举代码 我设法使用基本的方法相对轻松地实现了一个简单的枚举 即没有参数 macro rule 例如摘录 macro rules enum helper type ident name
  • 是否可以恢复损坏的“interned”字节对象

    众所周知 小bytes 对象由 CPython 自动 驻留 类似于intern https docs python org 3 library sys html sys intern 字符串函数 更正 As 解释了 https stacko
  • Project Reactor 中的预取是什么意思?

    我正在使用 Project Reactor 并且正在使用Flux flatMapIterable https projectreactor io docs core release api reactor core publisher Fl
  • 将 Webpack 与 HTTP/2 结合使用有什么价值

    我正在开始一个新项目 并且我正在尝试前瞻性地思考它 我过去使用过 Browserify 对于我的新项目 我想使用 Webpack Rollup 或 SystemJS Webpack 看起来是迄今为止最成熟的 具有大量出色的功能 不过 我担心
  • 从 C# 中的接口创建对象

    仅给定一个接口 是否可以从中创建一个对象 就像是 var obj new IWidget 我知道这段代码是不正确的 VS 仍然无法创建 IWidget 的实例 我所处的上下文中 我的项目引用了接口 并且我想创建具体对象并从方法返回它们 但我
  • anaconda如何选择cudatoolkit

    我有多个 anaconda 环境 上面安装了不同的 cuda 工具包 环境1有cudatoolkit 10 0 130 环境2有cudatoolkit 10 1 168 环境3有cudatoolkit 10 2 89 我通过运行找到了这些c
  • 空样式 (.css/.scss) 文件

    当我创建 Angular 应用程序时 我使用 CLI 来生成组件 在开发应用程序一段时间后 我为每个组件都有样式文件 但其中大部分是空的 当我检查声纳时 空样式文件中有代码气味 删除这个空样式表 在此文件末尾添加一个空的新行 我应该删除声纳
  • 重定向到用户登录后尝试访问的页面

    一直在阅读一些内容来找到答案 但运气不太好 我有一个网站 成员可以匿名浏览该网站 但某些页面受到限制 一旦成员单击需要登录才能查看的链接 我就会将其重定向到登录页面 我面临的问题是我不知道如何将会员重定向到他们登录后试图访问的页面 他们试图
  • JavaScript 图像缩放与 CSS3 变换,如何计算原点? (举例)

    我正在尝试实现图像缩放效果 有点类似于 Google 地图的缩放效果 但具有固定位置图像网格 我已经在这里上传了到目前为止我所拥有的示例 http www dominicpettifer co uk Files MosaicZoom htm
  • 向 bison/jison 计算器语言添加函数

    我正在尝试扩展吉森计算器示例 http zaach github io jison try 具有一些简单的功能 我对解析和 bison jison 相当陌生 但这是我到目前为止所拥有的一些内容 lexical grammar lex var
  • History.js 有没有办法知道何时按下后退按钮

    我已经开始测试历史 js https github com balupton history js 在了解了它的工作原理并且没有popstate 而是有statechange 我正在寻找一种在按下浏览器后退按钮时有所不同的方法 原因是我需要
  • Linux 上的 Squeak SMTP

    我正在使用 Squeak 5 类 SecureSMTPClient 通过 SSL TLS 发送电子邮件 它在我的 Windows 机器上运行良好 感谢答案那个问题 https stackoverflow com questions 3761
  • 使用可变长度数组有任何开销吗?

    使用可变长度数组有一些开销吗 数组的大小可以在运行时通过命令行参数传递吗 与自动和动态分配数组相比 为什么要引入它 VLA 确实有一些开销 与 普通 命名的编译时大小的数组相比 首先 它具有运行时长度 而且该语言为您提供了在运行时获取数组实
  • 从返回响应数据的 Fetch Post 获取数据

    我在带有 redux 的 React 应用程序中使用交叉获取 在我的减速器中 我使用 cross fetch 的 post 方法将一些数据保存到数据库中 我的调用返回一个响应 其中包含一些我需要在保存后分配给状态的数据 但我在解析数据时遇到
  • 当我直到运行时才知道长度时,如何声明数组?

    我最初有一个数组 1 1000 它被定义为全局变量 但现在我需要它是 n 而不是 1000 直到后来我才找到 n 在填充数组之前我知道 n 是什么 但我需要它是全局的 因此需要一种在运行时定义全局数组的大小的方法 上下文是通过文件中字节的线
  • 电话号码中的正则表达式可选空格[重复]

    这个问题在这里已经有答案了 可能的重复 用于电话号码验证的综合正则表达式 https stackoverflow com questions 123559 a comprehensive regex for phone number val
  • Pig 和 Hive 之间的区别?为什么两者都有? [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 我的背景 进入 Hadoop 世界已经 4 周了 使用 Cloudera 的 Hadoop VM 涉足 Hive Pig 和 Hadoop 读过
  • 片段着色器 - 确定整个(单色)图像的最小/最大值并使用它们进行进一步的像素操作

    我想正常化单色图像像素以这种方式最小值为黑色 最大值为白色 并且两者之间的值按比例分布 目前我在 canvas 中分两步完成 但我相信在 WebGL 中应该更快 我可以想象通过片段着色器操纵颜色 但我找不到任何有效的方法来 1 确定图像的实