Finding an equally spread subselection of XY-points

5 views (last 30 days)
I have a big list of 2D points with XY-coordinates. I want to find a subselection of those which are equally spread.
One of the methods I used for this is the follwing: First I make a grid with dx and dy as the desired distance between the points of the subselection. Then for every square of the grid, find the point closest to the center. This way I get a subselection.
You can see the result in attached graphs. The unfilled scatter plot are the input points and the filled scatter plot are the remaining output points of the sub selection.
As you can see in the second picture. This doesn't give a nice distribution in certain cases. Does any of you have an idea how to improve this? I don't really know any terms to google on to find algorithms.
Thanks in advance!

Answers (1)

Image Analyst
Image Analyst on 22 Jan 2018
Try this:
% Make 100 randomly located points between 0 and 100
x = 100 * rand(1, 100);
y = ones(1, length(x));
subplot(2, 1, 1);
plot(x, y, 'bs');
grid on;
% Make linearly spaced "desired" locations
% from 10 to 90 spaced every 10.
desiredx = 10:10:90;
% Find which of the actual data is closest to the desired data.
for k = 1 : length(desiredx)
[minDistance, index(k)] = min(abs(x - desiredx(k)));
end
% Extract the closest points.
closestx = x(index);
y = ones(1, length(closestx));
% Plot them
subplot(2, 1, 2);
plot(closestx, y, 'rs');
grid on;
  4 Comments
Image Analyst
Image Analyst on 22 Jan 2018
Why wouldn't it work in 2-D? I didn't have your y values so I just used 1 but I don't see why it wouldn't work with any y values. Attach your data if you want.
Be aware that the interparc goes for uniform distances along the arc, not just uniform in the x or y direction. This is a different concept. You have to decide which way you want it.
Jordy W
Jordy W on 23 Jan 2018
Edited: Jordy W on 23 Jan 2018
For example, if you take the following (not so random) input for the script you posted:
a= 39.5;
b= 40.7;
c= 39 * rand(1, 40);
d= 60 + 40 * rand(1, 40);
x=[a,b,c,d];
In that case it will find close points at around 40. I think this has something to do with the fact that I have a sparse input. This behavior is more apparent with the large 2D datasets I have.
Additionally, I'm not really sure about how to implement the interparc you posted to my scenario. In the screenshot I posted all input points are along a line, but they may be branching out, crossing, randomly stopping, etc.

Sign in to comment.

Categories

Find more on Historical Contests in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!