finding interior or exterior points

4 vues (au cours des 30 derniers jours)
Mohammad Golam Kibria
Mohammad Golam Kibria le 28 Juin 2011
Hi, I have a matrix as follows: I =
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 1 1 1 0 0 1
0 0 0 0 1 0 1
0 0 0 1 0 1 1
0 0 0 0 0 0 0
L=bwlabel(I)
L =
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 1 1 1 0 0 1
0 0 0 0 1 0 1
0 0 0 2 0 1 1
0 0 0 0 0 0 0
Here label 1 makes a continuous curve line. I need to know where point (5,4) belongs to, upper portion or lower portion. Thanks

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 28 Juin 2011
Have matrix
I =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 1 1 0
0 0 1 0 0 1
0 0 1 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
1 0 0 0 1 0
0 1 0 0 1 0
0 0 1 0 1 0
0 0 1 0 1 0
0 0 1 0 1 0
0 0 0 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
We need to know where point (5,4) belongs to, upper portion or lower portion.
Variant of solution.
idx = {5,4};
BW2 = bwmorph(I,'diag');
L = bwlabel(~BW2);
Id1 = bwdist(I,'chessboard') == 1;
for i1 = 1:max(L(:))
L(bwdist(L == i1,'chessboard')==1 & Id1) = i1;
end
if L(idx{:}) == L(1,1), disp('pixel in upper portions' );
elseif L(idx{:}) == L(end,1), disp('pixel in lower portions' );
else disp('pixel on boundaries of portions' );
end
L = bwlabel(~BW2,4);
if L(idx{:}) == max(L(1,:)), disp('pixel in upper portions' );
elseif L(idx{:}) == max(L(end,:)), disp('pixel in lower portions' );
else disp('pixel on boundaries of portions' );
end

Plus de réponses (1)

Walter Roberson
Walter Roberson le 28 Juin 2011
The upper and lower portions are the same, as your curve of label 1 does not partition the space: you can go around by way of (3,1) to pass between "upper" and "lower" without encountering any "1".

Catégories

En savoir plus sur Propagation and Channel Models 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