Effacer les filtres
Effacer les filtres

Find inner points among a set of points on a regular grid

6 vues (au cours des 30 derniers jours)
Kai
Kai le 6 Sep 2018
Modifié(e) : Matt J le 6 Sep 2018
I am dealing with the following problem:
Given a two-dimensional regular grid G = [a*h:h:b*h]x[c*h:h:d*h] and a subset S of G (i.e. a collection of knots on G), find the elements of S which lie on the inner of a 4x4 region of points of S.
In my situation, S usually looks like an "island" of points, and I am trying to select the points which do not lie on the coast, so to say. You could also think of a chess board with many kings placed and you want to find those kings which are unable to move (I know, "many kings" is a little imaginary). A 3x3 region as a selection criterion would be right for this situation actually, but it could lead to "one-dimensional lines" of inner points, which is not what I want (since I am actually interested in the regions between four inner points).
I made some straightforward implementation: When considering a point P, I run four loops which check whether P is the (2,2), (2,3), (3,2) or (3,3) position of such a 4x4 region respectively. Inside such a loop, for all other 15 positions of the 4x4 regions I check if S contains a point at this position. If there exist points at all 15 positions, the point P is marked as an inner point and I end the loops using the break command.
The implementation works, however it is quite costly. In my overall program, I have several such subsets S, and I would like to work with grids as fine as possible (resulting in large sets S). Checking 15 positions as above means running the isempty command 15 times, and the input for this command consists of four inequations each time (checking both coordinates seperately and using some eps tolerance bound, since sometimes there are rounding issues), each inequation being checked for every element of S.
I am wondering if there is some more elegant and quicker way to solve the problem, without spending weeks of defining some efficient searching algorithm or so. Perhaps there is even some Matlab function which I can use but haven't thought of (I searched using some keywords, but did not find anything useful).

Réponses (2)

KSSV
KSSV le 6 Sep 2018
Read about inpolygon.
  4 commentaires
KSSV
KSSV le 6 Sep 2018
Try knnsearch or rangesearch
Kai
Kai le 6 Sep 2018
Hmm, rangesearch could be an idea. I will try that, thank you!

Connectez-vous pour commenter.


Matt J
Matt J le 6 Sep 2018
Modifié(e) : Matt J le 6 Sep 2018
Make a binary map BW of S and use imerode,
[I,J]=find( imerode(BW,ones(4));

Catégories

En savoir plus sur Elementary Polygons dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by