MATLAB: Close loop

closeregion

I =
0 0 0 0 0 0 0
0 1 1 0 1 1 0
1 0 1 0 1 0 1
0 1 1 0 1 0 1
0 0 0 0 1 1 0
0 0 0 0 0 0 0
I need how many closed regions in the matrix. Here obviously two.Is there any one to help?

Best Answer

B = bwboundaries(I,8,'noholes')