How can I calculate the number of the neighbours for each cell?

2 vues (au cours des 30 derniers jours)
Alaa
Alaa le 1 Mar 2016
I want to calculate the percentage of hexagonal cells in a binary image, which means the number of the cells that have another 6 neighbours cells. I'm looking for a function that can do that in Matlab. I've tried different Matlab functions such as regionprops, and bwconncomp. However, no one works for me. is there any idea.
A simple image is here:

Réponses (1)

Image Analyst
Image Analyst le 2 Mar 2016
Modifié(e) : Image Analyst le 2 Mar 2016
Threshold for black. Then call bwlabel(). Then call imdilate() to grow out the regions one layer until they touch. Then call graycomatrix to find out what number region touches each other number region. If they don't touch, the count will be zero in the result of graycomatrix(). Just sum up the number of non-zero columns to count the number of neighbors. No, I don't have a demo, so give it a try and share your code if you can't get it working.

Catégories

En savoir plus sur Image Segmentation and Analysis 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