detect closed shapes formed by several arrays of points
5 ビュー (過去 30 日間)
古いコメントを表示
I plot several arrays containing xy-coordinates of points (using plot(x,y)) and obtain a plot with some curves. The curves form some very distinctive closed shapes (that is, the points describing the curves lie close to each other).
It's needed to "recognize" the closed shapes and to fill them. The coordinates of points forming the shapes and their order are given.
Is it possible without shape recognition tools of the Image Processing Toolbox? If not, then how it can be possibly done with the Image Processing Toolbox?
Any suggestions are welcome!
P.S.: A possible example with 3 closed shapes to detect is given below. The points' coordinates are too lengthy to publish.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155621/image.jpeg)
2 件のコメント
Image Analyst
2014 年 1 月 26 日
Probably. Here's a suggestion. Attach screenshots or images so we can visualize what you're talking about.
採用された回答
Image Analyst
2014 年 1 月 27 日
You can do this with the Image Processing Toolbox. There is a function called poly2mask that will give you a binary image that you can then pass in to regionprops to get the centroid.
binaryImage = poly2mask(xVertices, yVertices, rows, columns);
[labeledImage, numberOfRegions] = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Centroid');
allCentroids = [measurements.Centroid];
xCentroids = allCentroids(:,1);
yCentroids = allCentroids(:,2);
But I think poly2mask may combine the 3 regions into one. You'd have to try. You can attach your data via a script or .mat file if you want.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!