3D matrix with various chain!!
Mostra commenti meno recenti
If I have U3 matrix as:
U3(:,:,1) = [
0 , 0 , 0 , 0 , 0;
0 , 0 , 0 , 0 , 0;
0 , 1 , 0 , 0 , 1;
0 , 0 , 0 , 0 , 0;
0 , 0 , 0 , 0 , 0
]
U3(:,:,2) = [
0 , 0 , 0 , 0 , 0;
0 , 0 , 0 , 0 , 0;
0 , 1 , 0 , 0 , 1;
0 , 1 , 0 , 0 , 0;
0 , 1 , 0 , 0 , 0
]
U3(:,:,3) = [
0 , 0 , 0 , 0 , 0;
0 , 0 , 0 , 0 , 0;
0 , 1 , 0 , 0 , 1;
0 , 0 , 0 , 0 , 0;
0 , 0 , 0 , 0 , 0
]
I assumed that these coordinates can be represented as an individual chain U3(3,2,1) and U3(3,2,2)and U3(4,2,2) and U3(5,2,2)and U3(3,2,3). and the other coordinates as another individual chain U3(3,4,1) and U3(3,4,2) and U3(3,4,3).
How can I give each chain a similar individual number? EX.
U3(3,2,1) and U3(3,2,2)and U3(4,2,2) and U3(5,2,2)and U3(3,2,3)=2
U3(3,4,1) and U3(3,4,2) and U3(3,4,3)=3
Risposta accettata
Più risposte (3)
Oleg Komarov
il 17 Ago 2012
Modificato: Oleg Komarov
il 17 Ago 2012
If you have the Image Processing Toolbox:
CC = bwconncomp(U3);
labelmatrix(CC)
Image Analyst
il 20 Ago 2012
topPlane = squeeze(U3(1, :, :));
bottomPlane = squeeze(U3(end, :, :));
if any(topPlane(:)) || any(bottomPlane(:))
break; % Bail out of the while loop.
end
6 Commenti
Image Analyst
il 20 Ago 2012
Perhaps I don't know what you mean. My code will enter the "if" if there is a 1 in the top row or bottom row of the three U3 planes you show. Both of your two examples have that so that's why both will display OK (in my code it would have hit the break line). If that's not what you want then explain what you want. For some irregularly shaped grouping of 1's, there is no "chain terminal" that I know of. Let's say the blob is shaped like a star. What is/are the terminals?
Image Analyst
il 20 Ago 2012
Change from OR to AND:
if any(topPlane(:)) && any(bottomPlane(:))
Hisham
il 20 Ago 2012
Categorie
Scopri di più su Labels and Annotations in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!