如何计算 0 到 360 之间的色调值的平均值和标准差?

发布于 2024-12-16 02:38:07 字数 132 浏览 3 评论 0原文

假设使用简单的 HSV 颜色模型获取 5 个色调样本,其值为 355、5、5、5、5,所有色调均为红色,并且就感知而言彼此“相邻”。但简单平均值为 75,远离 0 或 360,接近黄绿色。

计算这个平均值和相关标准差的更好方法是什么?

Suppose 5 samples of hue are taken using a simple HSV model for color, having values 355, 5, 5, 5, 5, all a hue of red and "next" to each other as far as perception is concerned. But the simple average is 75 which is far away from 0 or 360, close to a yellow-green.

What is a better way to calculate this mean and associated std?

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

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

发布评论

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

评论(2

萤火眠眠 2024-12-23 02:38:07

简单的解决方案是将这些角度转换为一组向量,从极坐标转换为笛卡尔坐标。

由于您正在处理颜色,因此请将其视为到 (a*,b*) 平面的转换。然后取这些坐标的平均值,然后再次恢复为极坐标形式。在matlab中完成,

theta = [355,5,5,5,5];
x = cosd(theta); % cosine in terms of degrees
y = sind(theta); % sine with a degree argument

现在,取x和y的平均值,计算角度,然后
从弧度转换回度数。

meanangle = atan2(mean(y),mean(x))*180/pi
meanangle =
       3.0049

当然,这个解法只对平均角有效。正如您所看到的,它直接产生与角度平均值一致的结果,其中我认识到 355 度实际上包裹到 -5 度。

mean([-5 5 5 5 5])
ans =
     3

要计算标准差,最简单的做法是

std([-5 5 5 5 5])
ans =
       4.4721

“是”,这需要我明确地进行换行。

The simple solution is to convert those angles to a set of vectors, from polar coordinates into cartesian coordinates.

Since you are working with colors, think of this as a conversion into the (a*,b*) plane. Then take the mean of those coordinates, and then revert back into polar form again. Done in matlab,

theta = [355,5,5,5,5];
x = cosd(theta); % cosine in terms of degrees
y = sind(theta); % sine with a degree argument

Now, take the mean of x and y, compute the angle, then
convert back from radians to degrees.

meanangle = atan2(mean(y),mean(x))*180/pi
meanangle =
       3.0049

Of course, this solution is valid only for the mean angle. As you can see, it yields a consistent result with the mean of the angles directly, where I recognize that 355 degrees really wraps to -5 degrees.

mean([-5 5 5 5 5])
ans =
     3

To compute the standard deviation, it is simplest to do it as

std([-5 5 5 5 5])
ans =
       4.4721

Yes, that requires me to do the wrap explicitly.

尛丟丟 2024-12-23 02:38:07

我认为 user85109 提出的方法是计算平均值的好方法,但不是标准差:
想象有三个角度:180、180、181,

平均值将被正确计算,作为一个大约等于 180 的数字,

但从 [180,180,-179] 中,您会计算出一个高方差,而实际上它接近于零

乍一看,我将分别计算半正角的均值和方差,[0 到 180] 和负角的均值和方差 [0,-180],稍后我将计算合并方差
https://www.emathzone.com/tutorials/basic-statistics/组合方差.html

考虑到全局平均值及其与局部平均值之间的差异必须在两个方向上计算:顺时针和逆时针,并且必须是正确的选择的。

I think the method proposed by user85109 is a good way to compute the mean, but not the standard deviation:
imagine to have three angles: 180, 180, 181

the mean would be correctly computed, as a number aproximately equal to 180

but from [180,180,-179] you would compute a high variance when in fact it is near zero

At first glance, I would compute separately the means and variances for the half positive angles , [0 to 180] and fot the negative ones [0,-180] and later I would compute the combined variance
https://www.emathzone.com/tutorials/basic-statistics/combined-variance.html

taking into account that the global mean and the difference between it and the local means has to be computed in both directions: clockwise and counterclockwise, and the the correct one has to be chosen.

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