2
$\begingroup$

My project is in the field of image processing. The output of a certain program would print the x and y coordinates in the image. I calculate the arithmetic mean of the points to get the mean coordinate. But some times I get one or two wrong points which in turn affects my arithmetic mean drastically. How do I find this point which occurs very much away from my ideal points.

For example: ideal case scenario: output is (1,1),(0,5),(5,0) and the center point becomes (2,2) real time scenario: output is (1,1),(0,5),(56,87) and the center becomes (19,31)
In this case I want to ignore (56,87) so that the center becomes (0.3,2)

If you could suggest a library in python to deal with the same I'd be very happy.

$\endgroup$
  • 1
    $\begingroup$ Suggesting libraries is off topic here. I don't quite understand your situation here, isn't the mean point just the center of the image? $\endgroup$ – gung May 25 '16 at 12:03
2
$\begingroup$

Use robust statistics such as the median and trimmed means.

e.g. if you have the points (0,1), (5,0) and (43, 77) then the median each axis is (5,1).

Trimmed means require larger examples. In the simplest case, you would simply ignore the 5% smallest and 5% largest values and compute the mean of the remainder only (in each axis).

$\endgroup$
1
$\begingroup$

Robust statistics (trimmed mean, or median) are a good basic way. Another nice robust mean you can consider is the Hodges Lehmann estimator which is slightly more computational intensive but pretty robust.

Personally, I like to use a basic outlier detection algorithm which also takes into account how noisy the data is. A basic outlier detection metric is the mahalanobis distance. After calculating the distance, you can trim the points which the highest score. And its not that computationally intensive to calculate.

Mahalanobis distance in itself is sensitive to outliers too. What you can do is run it iteratively a few times and peel off the data until you are satisfied. That way it becomes more robust.

Once you removed the outliers, you can find the mean on the remaining points.

$\endgroup$
0
$\begingroup$

If I understood well your question, you will have a (huge?) cluster of points and a few "outliers".

A way to suppress these points is to attribute a score to each point based on its k-nearest-neighbours.

Each score will be the sum of the euclidean distances to these k-nearest-neighbours and the outliers will have a really bigger score than the regular points so you will be able to suppress them.

$\endgroup$
  • $\begingroup$ This will not help much, because k-means is sensiti e to outliers, too. The cluster center will be far off from the real center. Because k-means uses squared deviations. $\endgroup$ – Anony-Mousse May 26 '16 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.