问题标签 [saturation-arithmetic]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
217 浏览

opengl - OpenGL handling float color saturation ("color overflow")?

I'm woking on a scientific visualisation using openGL where I try to basically create a "coloured fog" to illustrate a multidimensional field. I want the hue of the color to represent the direction of the field and the luminosity of the color to correspond to the intensity of the field.

I use GL_BLEND with glBlendFunc(GL_ONE, GL_ONE) to achieve additive blending of colors of the surfaces I create. The problem is: in some places the colors get saturated. For example:
(1, 0, 0) + (1, 0, 0) = (2, 0, 0), and when this is rendered it just becomes (1, 0, 0) (i.e. the "overflow" is just chopped off). And this is not the way I would like it to be handled. I would like to handle the overflow by preserving hue and luminocity, i.e.

(2, 0, 0) should be translated into (1, 0.5, 0.5) (i.e. a lighter red, red with twice the luminocity of "pure" red).

Is there any way to achieve this (or something similar) with OpenGL?

0 投票
0 回答
46 浏览

amazon-web-services - 如何使用 AWS EC2 t2.micro 解决饱和问题

实例 t2.micro 详细信息:ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20200716

您好,我在 EC2 实例上运行 python 脚本。这是一个非常简单的脚本,可以从网页中提取数据。我的实例过载非常快。

以下是一些监控图表:

在此处输入图像描述

在此处输入图像描述

如何为实例的持续运行完美设置实例?

0 投票
1 回答
47 浏览

css - In CSS, is filter: saturate(100) any slower than saturate(2)?

For CSS filters, would there be any difference is the browser's speed to process saturate(2) as compared to any of the following:

#xA;

I am just using saturate as an example here. Interested in learning the answer for all CSS filters.

0 投票
2 回答
148 浏览

java - 如何处理超出整数 MAX_VALUE 和 MIN_VALUE 的加法和减法?

以下是我要实现的一段代码:

但我没有得到令人满意的结果。例如,-2147483640-10 给我 2147483646。

我确信必须有一种更具体的方法来进行饱和。

0 投票
2 回答
127 浏览

performance - 快速饱和整数转换?

我想知道是否有任何快速的技巧来进行从 64 位无符号值到 32 位无符号值的饱和转换(如果它被推广到其他宽度会很好,但这是我关心的主要宽度关于)。我在谷歌上搜索到的大部分资源都用于饱和算术运算。

饱和转换将采用 64 位无符号值,如果输入值大于 2^32-1,则将未修改的值返回为 32 位值或 2^32-1。请注意,这不是默认的 C 强制转换截断行为。

我可以想象做类似的事情:

  • 测试上半部分是否设置了任何位
  • 如果是这样,则创建一个所有位设置的 32 位掩码,否则创建一个所有位未设置的掩码
  • 带掩码的按位或下半部分

但我不知道如何快速生成掩码。我在 Godbolt 中尝试了直接的分支实现,看看编译器是否会为我生成一个聪明的无分支实现,但没有运气。

这里的实现示例。

编辑:我的错误,问题是没有设置为使用优化

0 投票
1 回答
33 浏览

gcc - GCC 编译器:进行浮点运算时的奇怪行为,浮点值饱和到 65536,其中浮点为 4 个字节

[我试图计算一个浮点乘法,我观察到该值已经饱和到 65536 并且没有更新。

问题仅在于以下代码。] 1

上述代码的结果

我用在线 GCC 编译器试过这个问题仍然是一样的。

这与浮点精度有什么关系?编译器是否在运行期间优化了我的浮点精度?

有没有我可以添加的编译器标志来解决这个问题?

谁能指导我如何解决这个问题?

附上代码供参考

0 投票
1 回答
72 浏览

arm - 使用 ARM Neon 内在函数处理饱和整数乘法溢出的最有效方法是什么?

我在 2 个 16 位向量之间有以下乘法:

如果dxdy都足够大,结果会溢出。

我想钳制 MIN_INT16 和 MAX_INT16 值之间的乘积;

如果不先将值转换为 int32,我还没有找到一种方法。这就是我现在所做的:

有没有办法更有效地实现这一目标?