finding nearest label distance

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)
the follwoing code determines the nearest label, I need to know what is the distance of this label from that pixel?
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)
also need to know what is going on with the following code:
mmn = min(Md(Ll));

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 6 月 15 日
1. coordinates of the nearest pixel
[ii jj] = find((Md == mmn)&Ll);
2. number of labels nearest pixel
out = L(ii,jj);
3. the minimum distance from the center pixel (4,1) to nearest pixel which belongs to a nearest label
mmn = min(Md(Ll));
  1 件のコメント
Mohammad Golam Kibria
Mohammad Golam Kibria 2011 年 6 月 15 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by