Similar to another question I asked here ( https://www.mathworks.com/matlabcentral/answers/412569-counting-the-number-of-gaps-in-a-binary-image ) I would like to count the duration of sequential values, separately for both black and white pixels. Currently the matrix I imported (attached) has black pixels with a value of 0, white are 255.
For example, if I have an example matrix:
255 255 255 0 0 255 0 255 255 255 0 0 0 255
255 0 0 0 0 255 255 255 255 0 255 255 0 255
I'd like to return for counting white pixels something like:
[2,1,3]
[4,1,1]
and for counting black pixels:
[3,1,3,1]
[1,4,2,1]
Is there a simple way to do this?
Best Answer