Question regarding finding the boundaries (vertices) of a series of data points on a 2D space

2 visualizaciones (últimos 30 días)
Hello,
I have a series of x,y data that form a distinct closed shape (this shape is not a geometrical shape like circle, sphere, etc.). My problem is how to test if a new given point would fall inside or outside this shape. It seems that "inpolygon" function of matlab can answer my question, but that function requires the vertices of the object but my data is x/y info of all points that form the shape. Is there an already available function that I can use to find the vertices of these data? also, do you have any other suggestion instead of "inpolygon" for inside/outside problem? I greatly appreciate your response.
Regards, NF
  2 comentarios
Sven
Sven el 15 de Nov. de 2011
So when you say "my data is x/y info of all points that form the shape", you mean that you *don't* have vertex data of the *boundaries*, you instead have data of every point *inside* the shape?
Are all of your points in a regular grid? Can you use bwboundaries?
It will certainly help if you can show a small piece of code that demonstrates your problem.
Noushin Farnoud
Noushin Farnoud el 15 de Nov. de 2011
Thanks Sven for your comment. You are right, I have every point inside the shape but not the vertices (or boundary). I can not simulate the exact data set with Matlab, but below is an example:
SIGMA1 =[0.05 0;0 0.05];
SIGMA2 =[0.05 0;0 0.05];
MU1 =[1 2];
MU2 =[2.005 2];
X = [mvnrnd(MU1,SIGMA1,2000);mvnrnd(MU2,SIGMA2,2000)];
scatter(X(:,1),X(:,2));ylim([- 3 3]);
I like to find the vertices of X so I can pass these vertices to 'inpolygon' function to decide if a given point (e.g., (-1,3)) is inside this shape or outside.
Thanks, NF

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 15 de Nov. de 2011
Have you taken a look at the convex hull, convhull()? That will give you the coordinates of the exterior perimeter points, just as if you have wrapped a rubber band around your points.
  1 comentario
Noushin Farnoud
Noushin Farnoud el 15 de Nov. de 2011
I have tried convexthull(), but because of the asymmetrical shape of my data (one side is tilted) it does not fit my shape properly. The problem comes when I use the generated border with inpolygon() function: many tested points that are outside the shape are found by inpolygon() to be inside the new convexhull generated border.

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by