问题
This question is intended to both abstract and focus one approach to my problem expressed at "Find the most colourful image in a collection of images".
Imagine we have a set of circles, each has a number of points around its circumference. We want to find a metric that gives a higher rating to a circle with points distributed evenly around the circle. Circles with some points scattered through the full 360° are better but circles with far greater numbers of points in one area compared to a smaller number in another area are less good.
The number of points is not limited.
Two or more points may coincide.
Coincidental points are still relevant. A circle with one point at 0° and one point at 180° is better than a circle with 100 points at 0° and 1000 points at 180°.
A circle with one point every degree around the circle is very good. A circle with a point every half degree around the circle is better.
In my other (colour based question) it was suggested that standard deviation would be useful but with caveat. Is this a good suggestion and does it cope with the closeness of 359° to 1°?
回答1:
This depends very much on what you actually want to achieve, if all you want is an even distribution then you could simply take all the points on the circle and average them, the closer this average is to the centre of the circle, the more even the distribution.
The caveat here though is that a distribution with 180 points at 0° and 180 points at 180° is just as good as a distribution with a single point at each degree. It's simply a matter of definitions if this is what you want or not.
A related, but a bit more complex concept is that of Geometric standard deviation: http://en.wikipedia.org/wiki/Geometric_standard_deviation
Another method would be like suggested in your other question, look at the mean number of points at all angles and see how much for each angle the number of points deviates from that.
i.e. let I
be your set of angles, say {0..359}
and v_i = #points at angle i, for i in I
, where a point p
is at angle i
iff floor(p) == i
. Then mean_v = (sum of v_i for i in I) / length(I)
and d_v_i = v_i - mean_v
.
Now you can define several metrics:
maximum of abs(d_v_i) for i in I
sum of abs(d_v_i) for i in I
sqrt((sum of (d_v_i^2) for i in I) / length(I))
(this is standard deviation)
There are lots more metrics you could take, any number that expresses the deviations contained in d_v_i would do the trick. It's all a matter of what exactly it is that you want that would determine the best metric.
One last note, seeing as you probably want to be comparing the metrics between various input sets, i.e. sets with varying number of data points, which, in your case is differently sized images. You probably need to scale the metrics according to the size of your input and depending on the metric you use you might need to scale in different ways. There's an easy way to validate your metric though, just calculate the metric for an image, then scale the image to a different size and calculate it again for the scaled image. Both metrics should be the same of course.
回答2:
So, I'd look at angle differences. The first step is to sort the points around the circle. Then sum the squared adjacent angle differences.
So, let's assume p[0] is 0 degrees, p[1] is 10, and p[2] is 20. Then the error is (10-0)^2 + (20-10)^2 + (360-20)^2.
You could also normalize by the number of points, or normalize each difference based on the optimal spacing for the number of points (abs(difference)-optimal)^2
You might also look at using perceptual color spaces rather than just RGB or HSV.
来源:https://stackoverflow.com/questions/4653899/most-thorough-distribution-of-points-around-a-circle