How to find the average Hue (or other "loop" value)?

Analyze color scheme of images, and need to take the average of hue. The problem is that hue is looped: after 359° should be zero.
In this situation, take the average of n? Consider that n is large and unprofitable to store all the numbers, you need some "adder".
June 27th 19 at 15:36
1 answer
June 27th 19 at 15:38
Solution
While the most successful method is as follows.

Go to the coordinates (x, y): x = cos(hue) · sat, y = sin(hue) · sat.
There you can get the average (x, y) and take atan2.

Find more questions by tags Algorithmsimage processingMathematicsWork with color