包围盒周围的指数衰减
我真的不知道如何表达这个问题,这很奇怪。
我有一个一维强度值数组和一个边界框(数组中的整数起点和终点)。我想保持边界框内的值相同,但以指数方式减少框外的值(即距离越远,减少的越多)。应该看起来像高斯分布,边界框所在的位置有一个平台。谁能举例说明我该如何做到这一点?今晚我的大脑不太正常,谢谢。
更新:
我用过这个:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
类似于
参数 t 吗?事实上,最后一个 else 分支可以被省略。
Something like
with a parameter t? Indeed the last else branch may be omitted.
您是否在问如何以指数方式减少,任意接近 0?
或者一些东西一开始会快速增加,当你进一步移动时会缓慢增加,即。指数的倒数?
如果您想要类似的东西(一开始增加很快,当你进一步增加时慢慢增加),并且有界,请参阅这个答案在 sigmoid 曲线上。
Are you asking how to decrease exponentially, getting arbitrarily close to 0?
or something which increases fast at first and slowly as you move further out ie. the inverse of the exponential?
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.
你想从本质上砍掉高斯的驼峰吗?
高斯类似于
I = I_0 exp(-aX^2)
。您的I
位于X
处,位于边界框宽度的一半处。然后你可以玩I_0
和a
直到你得到你想要的(选择一个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 haveI
atX
at half the width of your bounding box. Then you can play withI_0
anda
until you get what you want (choose anI_0
to get the correspondinga
, or vice versa).(Also,
X
is offset to the center of your bounding box. The above formula works forX
= 0.)