Identify neighbours in image after finding regionprops centroids

4 ビュー (過去 30 日間)
sr9497
sr9497 2022 年 3 月 19 日
編集済み: sr9497 2022 年 3 月 23 日
I have an example image with different RGB color values. I have used ColorThresholder to create a mask to get every different RGB color and then used regionprops (extrema and centroid) to get the corner points and centroids of each shape. I would now like to calculate the distance between neighbouring centroids and corner points. In other words, I would like to store the data in such a way that it is clear that the yellow and green squares are connected to the black one and that I can thereby easily calculate the distance between those centroids. What is the best way to store the data after using regionprops to be able to achieve this?
Any help or suggestion will be appreciated.

採用された回答

Matt J
Matt J 2022 年 3 月 19 日
編集済み: Matt J 2022 年 3 月 19 日
I would create a polyshape for each of the regions based on the extrema that you found. You can dtermine whether 2 polyshapes p_i and p_j border each other with,
P=intersect(polybuffer([p_i,p_j],smallnumber));
A(i,j) = (P.NumRegions>0)
Once you've done that for all pairs of regions i and j, you will have an adjacency matrix A which you can then use to build a graph object describing the region connectivity,
G=graph(A)

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by