input: C matrix 2xN (2D points)
output: C matrix 2xM (2D points) with equal or less points.
Lets say we have C matrix 2xN that contains several 2D points, and it looks something like that:
What we want is to group "close" points to one point, measured by the average of the other points. For example, in the second image, every group of blue circle will be one point, the point coordinate will be the average point off all points in the blue circle. also by saying "close", I mean that: their distance one to each other will be smaller then DELTA (known scalar). So wanted output is:
About running time of the algorithm, I don't have upper-limit request but I call that method several times...
I am using Matlab, and what i have tried is this:
function C = ReduceClosePoints(C ,l_boundry) x_size = abs(l_boundry(1,1)-l_boundry(1,2)); %220 DELTA = x_size/10; T = ; for i=1:size(C,2) sum = C(:,i); n=1; for j=1:size(C,2) if i~=j %not same point D = DistancePointToPoint(C(:,i),C(:,j)); if D < DELTA sum = sum + C(:,j); n=n+1; end end end sum = sum./n; %new point -> save in T matrix T = [T sum]; end C = T; end
And its not working :(
Also I am new to Matlab.
Thank you for your help!!