assume the 2d array as territory, and determine by used and un-used spaces, calculate the no of object in that territory
[ 1 ][ 1 ][ 0 ][ 0 ][ 1 ]
[ 1 ][ 1 ][ 0 ][ 0 ][ 0 ]
[ 0 ][ 0 ][ 1 ][ 0 ][ 0 ]
[ 0 ][ 0 ][ 0 ][ 1 ][ 1 ]
( 1 ) used space
( 0 )un-used space
in the above example there are 4 object in the territory.
number of objects are calculated by grouping adjecent area,and then calculate the total adjecent areas