How to Detect the boundary of blob

test samples included: noblob.txt, smallmatrix.txt and smallermatrix.txt