필터 지우기
필터 지우기

finding nearest label

조회 수: 1 (최근 30일)
Mohammad Golam Kibria
Mohammad Golam Kibria 2011년 6월 15일
Hi I have the following matrix
I =
0 1 0 0 1 0
0 0 0 1 0 0
0 0 0 0 0 0
0 0 1 1 0 0
0 1 0 0 1 0
1 0 0 0 0 1
and
L=bwlabel(I)
L =
0 2 0 0 3 0
0 0 0 3 0 0
0 0 0 0 0 0
0 0 1 1 0 0
0 1 0 0 1 0
1 0 0 0 0 1
and I know a position say (4,1). How to find the nearest label from the position (4,1)

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 6월 15일
M = zeros(size(L));
M(4,1) = 1;
Md = bwdist(M);
Ll = logical(L);
mmn = min(Md(Ll));
[ii jj] = find((Md == mmn)&Ll);
out = L(ii,jj)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by