So I have a binary matrix in Matlab. It is basically a blob (pixels of value 1) surrounded by a neutral background (value 0).
I want to figure out whether this blo
Code
%// Assuming bw1 is the input binary matrix
[L,num] = bwlabel( ~bw1 );
counts = sum(bsxfun(@eq,L(:),1:num));
[~,ind] = max(counts);
bw2 = ~(L==ind);
%// Output decision
[L,num] = bwlabel( bw1 );
if ~nnz(bw1~=bw2) && num==1
disp('Yes it is a simply connected blob.')
else
disp('Nope, not a simply connected blob.')
end