如何计算从0到360的色调值的平均值和标准偏差? [英] How to calculate mean and standard deviation for hue values from 0 to 360?

查看:1914
本文介绍了如何计算从0到360的色调值的平均值和标准偏差?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设使用用于颜色的简单HSV模型获取5个色调样本,具有值355,5,5,5,5,所有的红色色调和关于彼此的下一个。但是简单的平均值是75,远离0或360,接近黄绿色。



什么是更好的方法来计算这个平均值和相关的std?

解决方案

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



因为你使用颜色,所以认为这是一个转换(a *,b *)平面。然后取这些坐标的平均值,然后再次恢复为极坐标形式。在matlab中完成,

  theta = [355,5,5,5,5]; 
x = cosd(theta); %余弦以度数表示
y = sind(theta);具有度参数的%正弦

现在,取x和y的平均值,

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

当然,只对平均角。正如你所看到的,它直接产生与角度的平均值一致的结果,其中我认识到355度真的包裹到-5度。

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


b $ b

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

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

明确做包装。


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?

解决方案

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.

这篇关于如何计算从0到360的色调值的平均值和标准偏差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆