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

조회 수: 2 (최근 30일)
Alaa
Alaa 2016년 3월 1일
편집: Image Analyst 2016년 3월 2일
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:

답변 (1개)

Image Analyst
Image Analyst 2016년 3월 2일
편집: Image Analyst 2016년 3월 2일
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.

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by