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

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
  • Three.js 的外观似乎被翻转了

    我这里有一个演示 测试场地 http www myuplay com game test html or Backup http direct myuplay com game test html 由于某种原因 即使鼠标矢量是正确的 我的对
  • HTML5 画布旋转图像

    jQuery carregar click function var canvas document getElementById canvas var image document getElementById image var ele
  • WebGL 中的 AlphaFunctions?

    是否可以实现透明度低于 0 5 的片段被丢弃 而 alpha 高于 0 5 的片段渲染为不透明的效果 从我读到的来看 glEnable GL ALPHA TEST glAlphaFunc GL GREATER 0 5 这将是我正在寻找的 但
  • 如何使用 Fabric.js 在画布上画一条线

    我正在使用 Fabric js 在画布上画一条线 这是我的代码 但我没有得到任何输出 Line click function alert Line canvas add new fabric Line 50 100 200 200 left
  • JS中如何获取图像的DPI?

    我在 HTML5 画布上工作来计算图像上两点之间的距离 我想将以像素为单位的距离转换为厘米 我找到了一个公式 像素 2 54 DPI 所以我想知道是否可以在JS中获取DPI图像属性 或者 我可以使用最简单的方法从像素计算厘米吗 谢谢 您所要
  • 为什么我不能在 Konva.Shape.fillPatternImage(imageObj) 中使用 Konva.Image()?

    以下是来自的示例Konvajs http konvajs github io docs shapes Image html加载图像的库 var imageObj new Image imageObj onload function var
  • 为什么 HTML 5 画布中的矩形不是黑色的?

    下面是一个带有 canvas 标签的简单 HTML 5 页面 在画布上用黑色绘制一个矩形 并显示黑色文本 但由于某种原因 矩形实际上是灰色的 为了让它变成黑色 我必须在它上面画2到3次 这似乎表明存在某种阿尔法问题 但我不知道为什么会这样
  • EaselJS:单击鼠标更改形状填充颜色

    我在使用 EaselJS 时遇到了困难 基本上我想创建一个简单的网格并突出显示所选的实际元素 var stageWidth 800 stageHeight 600 cell size 50 w 16 h 12 n w h canvas st
  • 在画布上的精确位置创建输入文本字段?

    Canvas 可以绘制文本 但无法创建输入文本字段 这意味着必须在 html 中执行此操作 但是如何才能确保将该文本字段准确定位在您想要的位置呢 我希望能够在运行时以编程方式执行此操作 创建以下 HTML 结构以将输入框放置在画布上 div
  • 使用百分比而不是像素会改变 html 5 画布的属性吗?

    我正在练习 javascript 我正在尝试制作一个游戏 我希望画布元素是全屏的 因此我对高度和宽度属性使用了百分比 但是当我这样做时 它的行为与通常不同 当我运行调试代码时 它应该生成一个 50px x 50px 的盒子 但图形看起来比正
  • Three.js - 在自定义几何体上平滑兰伯特材质着色的问题

    我在 Three js 中创建了一个自定义几何体 现在 我想创建一个使用平滑阴影兰伯特材质的网格 使用循环 我创建了顶点数组 然后创建了面 然后我调用了 geometry computeCentroids geometry computeF
  • HTML5 画布/Flash。如何访问儿童影片剪辑并使其转到AndPlay?

    在 Flash 中 我的主时间轴中有 2 帧 第一个是选择语言 第二个包含导航栏 该导航栏是一个影片剪辑 其中包含项目 影片剪辑 这些 item movieclips 包含 2 个帧 每种语言一个 在 navigation bar movi
  • 将 WebGL 应用程序部署为本机 iOS 或 Android 应用程序?

    有谁知道如何将 WebGL 应用程序部署为本机 iOS 或 Android 应用程序 商业中间件是可以接受的 但开放项目会更好 谢谢 作为 Joris 答案的延伸 这似乎是基于内森 德弗里斯的作品 http atnan com blog 2
  • jquery画布图像下载

    我有我的画布元素和一些 div 单击后我希望打开下载 画布快照 现在我有 save live click function e var image canvas toDataURL image png true var imageEleme
  • 我可以使用 vh 和 vw 指定画布尺寸吗?

    我的代码是 var canvas document getElementById canvas ctx canvas getContext 2d ctx canvas width 40vw ctx canvas height 40vh 但它
  • 从 url 加载图像并绘制到 HTML5 Canvas

    我在从 javascript 中的 url 加载图像时遇到问题 下面的代码可以工作 但我不想从 html 加载图像 我想使用纯 JavaScript 从 url 加载图像 var c document getElementById myCa
  • 解决 Three.js / webGL 中的 gl_PointSize 限制

    我正在使用 Three js 创建交互式数据可视化 此可视化涉及渲染 68000 个节点 其中每个不同的节点具有不同的大小和颜色 最初我尝试通过渲染网格来实现此目的 但事实证明这非常昂贵 我当前的尝试是使用 Three js 粒子系统 每个
  • WebGL - 如何传递无符号字节顶点属性颜色值?

    我的顶点由具有以下结构的数组组成 Position colour float float float byte byte byte byte 传递顶点位置没有问题 gl bindBuffer gl ARRAY BUFFER this vbo
  • 在 JavaScript 函数中加载图像

    我有获取图像像素颜色的功能 function getImage imgsrc var img img src imgsrc var imageMap new Object img load function var canvas

随机推荐

  • 如何从 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 确定图像的实