MATLAB: Finding region

region

Hi I have a matrix as follows:
I=
1 1 0 0 0 0 0 0 0 0
0 0 1 1 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 0
0 0 0 0 0 0 0 0 0 0
Here 1 has divided the matrix in two parts I need to have the indices of these two separate parts. say idx1 will be upper zeros and idx2 contains lower zero indices.Can any one help.

Best Answer

BW2 = bwmorph(I,'diag');
L = bwlabel(~BW2);
Id1 = bwdist(I,'chessboard') == 1;
for i1 = 1:max(L(:))
L(bwdist(L == i1,'chessboard')==1 & Id1) = i1;
end
idx1 = find(max(L(1,:))==L);
idx2 = find(max(L(end,:))==L);
EDIT as at Sean
L = bwlabel(~I,4);
idx1 = find(max(L(1,:))==L);
idx2 = find(max(L(end,:))==L);