Labeling values in 1d array (vector)
조회 수: 6 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!