Finding neighbors of an object from labeled image

조회 수: 1 (최근 30일)
Philip
Philip 2011년 4월 1일
댓글: Alaa 2016년 3월 1일
I have used segmentation and labelling techniques to assign each object within an image a unigue number. For example, the sky will be given label 1, a tree may be given label 2, a person label 3, the ground label 4, and so on...
What I would like to do now is grab all the labels directly neighboring a specific object. For example, if I select the object of interest as label 3 (the person), I want to end up with a list of all the objects that the person directly neighbors. This would be the sky, and the ground (labels 1 and 4), but not the tree (label 2) as this is separated from the person.
Does anyone know of any good efficient methods for achieving this?
Thanks in advance!

답변 (1개)

David Young
David Young 2011년 4월 1일
One possibility:
% assume labelled array is called "labelled"
label = 8; % label of object to find neighbours of
object = labelled == label;
se = ones(3); % 8-connectivity for neighbours - could be changed
neighbours = imdilate(object, se) & ~object;
neighbourLabels = unique(labelled(neighbours));
disp(neighbourLabels);
  댓글 수: 1
Alaa
Alaa 2016년 3월 1일
please,How can improve this to find each cell the number of neighbours cells of corneal cells to calculate hexagonality coefficient (pleomorphism) of cells. thanks in advance.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by