包围盒周围的指数衰减

发布于 2024-10-21 00:33:33 字数 410 浏览 3 评论 0原文

我真的不知道如何表达这个问题,这很奇怪。

我有一个一维强度值数组和一个边界框(数组中的整数起点和终点)。我想保持边界框内的值相同,但以指数方式减少框外的值(即距离越远,减少的越多)。应该看起来像高斯分布,边界框所在的位置有一个平台。谁能举例说明我该如何做到这一点?今晚我的大脑不太正常,谢谢。

更新:

我用过这个:

if (j < low) a[j] *= Logistic(t*(j + (6f/t) - low));
else if (j > high) a[j] *= Logistic(-t*(j - (6f/t) - high));

private double Logistic(double x)
{
    return (1 / (1 + Math.Exp(-x)));
}

I didn't really know how to phrase this question, its quite strange.

I have a 1d array of intensity values, and a bounding box (integer start and end point in the array). I want to keep the values within the bounding box the same, but diminish the values outside the box in an exponential way (ie the further away they are the more they are diminished). Should look something like a gaussian with a plateau where the bounding box is. Can anyone give an example of how I could do this? My brain is not working right tonight, thanks.

UPDATE:

I used this:

if (j < low) a[j] *= Logistic(t*(j + (6f/t) - low));
else if (j > high) a[j] *= Logistic(-t*(j - (6f/t) - high));

private double Logistic(double x)
{
    return (1 / (1 + Math.Exp(-x)));
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喵星人汪星人 2024-10-28 00:33:33

类似于

if (n<low)
  a[n] *=  exp(-t*(low-n));
else if (n>high)
  a[n] *=  exp(-t*(n-high));
else 
  a[n] *=  1.0;

参数 t 吗?事实上,最后一个 else 分支可以被省略。

Something like

if (n<low)
  a[n] *=  exp(-t*(low-n));
else if (n>high)
  a[n] *=  exp(-t*(n-high));
else 
  a[n] *=  1.0;

with a parameter t? Indeed the last else branch may be omitted.

空心空情空意 2024-10-28 00:33:33

您是否在问如何以指数方式减少,任意接近 0?

value = 1 / e^(distance)

或者一些东西一开始会快速增加,当你进一步移动时会缓慢增加,即。指数的倒数?

value = ln(distance)

如果您想要类似的东西(一开始增加很快,当你进一步增加时慢慢增加),并且有界,请参阅这个答案在 sigmoid 曲线上。

Are you asking how to decrease exponentially, getting arbitrarily close to 0?

value = 1 / e^(distance)

or something which increases fast at first and slowly as you move further out ie. the inverse of the exponential?

value = ln(distance)

If you want something similar to that (increases fast at first, slowly as you get further out) that is bounded, see this answer on sigmoid curves.

荒路情人 2024-10-28 00:33:33

你想从本质上砍掉高斯的驼峰吗?

高斯类似于 I = I_0 exp(-aX^2)。您的 I 位于 X 处,位于边界框宽度的一半处。然后你可以玩 I_0a 直到你得到你想要的(选择一个 I_0 以获得相应的 a >,或反之亦然)。

(此外,X 偏移到边界框的中心。上述公式适用于 X = 0。)

You want to chop off the hump of the Gaussian, essentially?

The Gaussian is something like I = I_0 exp(-aX^2). You have I at X at half the width of your bounding box. Then you can play with I_0 and a until you get what you want (choose an I_0 to get the corresponding a, or vice versa).

(Also, X is offset to the center of your bounding box. The above formula works for X = 0.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文