I have a set of (x,y) coordinates that enclose a irregular shape, I want to extract all the points that are inside that particular region. How should i approach this.

3 次查看(过去 30 天)
Basically I have an image in which I have marked certain regions, I want to know about all the points inside that region.

采纳的回答

Walter Roberson
Walter Roberson 2015-10-10
There are an infinite number of points inside any non-degenerate polygon (for degenerate polygons, you need to define "inside" with some care to boundary conditions.)
If you are asking about matrix coordinates then poly2mask() and then if you want you can extra the content of the matrix according to the mask.

更多回答(1 个)

Image Analyst
Image Analyst 2015-10-17
If you want the pixel values, then you can do
mask = poly2mask(x, y, rows, columns);
pixelValues = grayImage(mask);
If you want other things, like the area of the shape, then see my Image Processing Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by