Labeling values in 1d array (vector)
Afficher commentaires plus anciens
I am working on image processing specially on segmentation. I have a vector A (1D array) that contains some values, I want to specify the zero values using the following lines of code
A = [1 1 2 1 0 0 1 1 3 3 0 0 0 0 0 0 1 1 0 1 0 0 1 5 1 0 0 0 0 1 1];
blackPixel = A==0;
the result is blackPixel =[0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 0 0 1 0 1 1 0 0 0 1 1 1 1 0 0]
So, my question is how to label only three or more adjacent ones. For example, if I write the following command
[labeledRegions, numberOfRegions] = bwlabel(blackPixel);
I get the following results labeledRegions=[0 0 0 0 1 1 0 0 0 0 2 2 2 2 2 2 0 0 3 0 4 4 0 0 0 5 5 5 5 0 0] and numberOfRegions = 5. But I need to label only the 3 or more adjacent zeros and get the following results: labeledRegions=[0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 2 2 2 2 0 0] and numberOfRegions = 2 Notice that the number 3 is an example. In my work I need to specify, for example, 7 adjacent zeros.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Segmentation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!